]> Untitled Git - lemmy.git/blob - crates/apub/src/protocol/objects/person.rs
GNU social compatibility (#2100)
[lemmy.git] / crates / apub / src / protocol / objects / person.rs
1 use crate::{
2   objects::person::ApubPerson,
3   protocol::{objects::Endpoints, ImageObject, SourceCompat},
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 }
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 usually fixed after that
25   pub(crate) preferred_username: String,
26   pub(crate) inbox: Url,
27   /// mandatory field in activitypub, lemmy currently serves an empty outbox
28   pub(crate) outbox: Url,
29   pub(crate) public_key: PublicKey,
30
31   /// displayname
32   pub(crate) name: Option<String>,
33   pub(crate) summary: Option<String>,
34   pub(crate) source: Option<SourceCompat>,
35   /// user avatar
36   pub(crate) icon: Option<ImageObject>,
37   /// user banner
38   pub(crate) image: Option<ImageObject>,
39   pub(crate) matrix_user_id: Option<String>,
40   pub(crate) endpoints: Option<Endpoints>,
41   pub(crate) published: Option<DateTime<FixedOffset>>,
42   pub(crate) updated: Option<DateTime<FixedOffset>>,
43 }