]> Untitled Git - lemmy.git/blob - crates/apub/src/protocol/objects/person.rs
Change Person, Instance types (#2200)
[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 chrono::{DateTime, FixedOffset};
6 use lemmy_apub_lib::{object_id::ObjectId, signatures::PublicKey};
7 use serde::{Deserialize, Serialize};
8 use serde_with::skip_serializing_none;
9 use url::Url;
10
11 #[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
12 pub enum UserTypes {
13   Person,
14   Service,
15   Organization,
16 }
17
18 #[skip_serializing_none]
19 #[derive(Clone, Debug, Deserialize, Serialize)]
20 #[serde(rename_all = "camelCase")]
21 pub struct Person {
22   #[serde(rename = "type")]
23   pub(crate) kind: UserTypes,
24   pub(crate) id: ObjectId<ApubPerson>,
25   /// username, set at account creation and usually fixed after that
26   pub(crate) preferred_username: String,
27   pub(crate) inbox: Url,
28   /// mandatory field in activitypub, lemmy currently serves an empty outbox
29   pub(crate) outbox: Url,
30   pub(crate) public_key: PublicKey,
31
32   /// displayname
33   pub(crate) name: Option<String>,
34   pub(crate) summary: Option<String>,
35   #[serde(default)]
36   #[serde(deserialize_with = "crate::deserialize_skip_error")]
37   pub(crate) source: Option<Source>,
38   /// user avatar
39   pub(crate) icon: Option<ImageObject>,
40   /// user banner
41   pub(crate) image: Option<ImageObject>,
42   pub(crate) matrix_user_id: Option<String>,
43   pub(crate) endpoints: Option<Endpoints>,
44   pub(crate) published: Option<DateTime<FixedOffset>>,
45   pub(crate) updated: Option<DateTime<FixedOffset>>,
46 }