]> Untitled Git - lemmy.git/blob - crates/apub/src/protocol/objects/person.rs
Refactoring apub code
[lemmy.git] / crates / apub / src / protocol / objects / person.rs
1 use crate::{
2   fetcher::object_id::ObjectId,
3   objects::person::ApubPerson,
4   protocol::{ImageObject, Source},
5 };
6 use activitystreams::{actor::Endpoints, unparsed::Unparsed, url::Url};
7 use chrono::{DateTime, FixedOffset};
8 use lemmy_apub_lib::signatures::PublicKey;
9 use serde::{Deserialize, Serialize};
10 use serde_with::skip_serializing_none;
11
12 #[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
13 pub enum UserTypes {
14   Person,
15   Service,
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 can never be changed
26   pub(crate) preferred_username: String,
27   /// displayname (can be changed at any time)
28   pub(crate) name: Option<String>,
29   pub(crate) summary: Option<String>,
30   pub(crate) source: Option<Source>,
31   /// user avatar
32   pub(crate) icon: Option<ImageObject>,
33   /// user banner
34   pub(crate) image: Option<ImageObject>,
35   pub(crate) matrix_user_id: Option<String>,
36   pub(crate) inbox: Url,
37   /// mandatory field in activitypub, currently empty in lemmy
38   pub(crate) outbox: Url,
39   pub(crate) endpoints: Endpoints<Url>,
40   pub(crate) public_key: PublicKey,
41   pub(crate) published: Option<DateTime<FixedOffset>>,
42   pub(crate) updated: Option<DateTime<FixedOffset>>,
43   #[serde(flatten)]
44   pub(crate) unparsed: Unparsed,
45 }