]> Untitled Git - lemmy.git/blob - crates/apub/src/protocol/objects/person.rs
Merge pull request #1877 from LemmyNet/refactor-apub-2
[lemmy.git] / crates / apub / src / protocol / objects / person.rs
1 use crate::{
2   objects::person::ApubPerson,
3   protocol::{objects::Endpoints, ImageObject, Source},
4 };
5 use activitystreams::{unparsed::Unparsed, url::Url};
6 use chrono::{DateTime, FixedOffset};
7 use lemmy_apub_lib::{object_id::ObjectId, signatures::PublicKey};
8 use serde::{Deserialize, Serialize};
9 use serde_with::skip_serializing_none;
10
11 #[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
12 pub enum UserTypes {
13   Person,
14   Service,
15 }
16
17 #[skip_serializing_none]
18 #[derive(Clone, Debug, Deserialize, Serialize)]
19 #[serde(rename_all = "camelCase")]
20 pub struct Person {
21   #[serde(rename = "type")]
22   pub(crate) kind: UserTypes,
23   pub(crate) id: ObjectId<ApubPerson>,
24   /// username, set at account creation and can never be changed
25   pub(crate) preferred_username: String,
26   /// displayname (can be changed at any time)
27   pub(crate) name: Option<String>,
28   pub(crate) summary: Option<String>,
29   pub(crate) source: Option<Source>,
30   /// user avatar
31   pub(crate) icon: Option<ImageObject>,
32   /// user banner
33   pub(crate) image: Option<ImageObject>,
34   pub(crate) matrix_user_id: Option<String>,
35   pub(crate) inbox: Url,
36   /// mandatory field in activitypub, currently empty in lemmy
37   pub(crate) outbox: Url,
38   pub(crate) endpoints: Endpoints,
39   pub(crate) public_key: PublicKey,
40   pub(crate) published: Option<DateTime<FixedOffset>>,
41   pub(crate) updated: Option<DateTime<FixedOffset>>,
42   #[serde(flatten)]
43   pub(crate) unparsed: Unparsed,
44 }