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