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