1 use crate::newtypes::{DbUrl, InstanceId, PersonId};
2 #[cfg(feature = "full")]
3 use crate::schema::{person, person_follower};
4 use serde::{Deserialize, Serialize};
5 use serde_with::skip_serializing_none;
6 #[cfg(feature = "full")]
8 use typed_builder::TypedBuilder;
10 #[skip_serializing_none]
11 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
12 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
13 #[cfg_attr(feature = "full", diesel(table_name = person))]
14 #[cfg_attr(feature = "full", ts(export))]
19 /// A shorter display name.
20 pub display_name: Option<String>,
21 /// A URL for an avatar.
22 pub avatar: Option<DbUrl>,
23 /// Whether the person is banned.
25 pub published: chrono::NaiveDateTime,
26 pub updated: Option<chrono::NaiveDateTime>,
27 /// The federated actor_id.
29 /// An optional bio, in markdown.
30 pub bio: Option<String>,
31 /// Whether the person is local to our site.
34 pub private_key: Option<String>,
36 pub public_key: String,
38 pub last_refreshed_at: chrono::NaiveDateTime,
39 /// A URL for a banner.
40 pub banner: Option<DbUrl>,
41 /// Whether the person is deleted.
43 #[serde(skip_serializing)]
46 pub shared_inbox_url: Option<DbUrl>,
47 /// A matrix id, usually given an @person:matrix.org
48 pub matrix_user_id: Option<String>,
49 /// Whether the person is an admin.
51 /// Whether the person is a bot account.
52 pub bot_account: bool,
53 /// When their ban, if it exists, expires, if at all.
54 pub ban_expires: Option<chrono::NaiveDateTime>,
55 pub instance_id: InstanceId,
58 #[derive(Clone, TypedBuilder)]
59 #[builder(field_defaults(default))]
60 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
61 #[cfg_attr(feature = "full", diesel(table_name = person))]
62 pub struct PersonInsertForm {
66 pub public_key: String,
68 pub instance_id: InstanceId,
69 pub display_name: Option<String>,
70 pub avatar: Option<DbUrl>,
71 pub banned: Option<bool>,
72 pub published: Option<chrono::NaiveDateTime>,
73 pub updated: Option<chrono::NaiveDateTime>,
74 pub actor_id: Option<DbUrl>,
75 pub bio: Option<String>,
76 pub local: Option<bool>,
77 pub private_key: Option<String>,
78 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
79 pub banner: Option<DbUrl>,
80 pub deleted: Option<bool>,
81 pub inbox_url: Option<DbUrl>,
82 pub shared_inbox_url: Option<DbUrl>,
83 pub matrix_user_id: Option<String>,
84 pub admin: Option<bool>,
85 pub bot_account: Option<bool>,
86 pub ban_expires: Option<chrono::NaiveDateTime>,
89 #[derive(Clone, TypedBuilder)]
90 #[cfg_attr(feature = "full", derive(AsChangeset))]
91 #[cfg_attr(feature = "full", diesel(table_name = person))]
92 #[builder(field_defaults(default))]
93 pub struct PersonUpdateForm {
94 pub display_name: Option<Option<String>>,
95 pub avatar: Option<Option<DbUrl>>,
96 pub banned: Option<bool>,
97 pub updated: Option<Option<chrono::NaiveDateTime>>,
98 pub actor_id: Option<DbUrl>,
99 pub bio: Option<Option<String>>,
100 pub local: Option<bool>,
101 pub public_key: Option<String>,
102 pub private_key: Option<Option<String>>,
103 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
104 pub banner: Option<Option<DbUrl>>,
105 pub deleted: Option<bool>,
106 pub inbox_url: Option<DbUrl>,
107 pub shared_inbox_url: Option<Option<DbUrl>>,
108 pub matrix_user_id: Option<Option<String>>,
109 pub admin: Option<bool>,
110 pub bot_account: Option<bool>,
111 pub ban_expires: Option<Option<chrono::NaiveDateTime>>,
114 #[derive(PartialEq, Eq, Debug)]
115 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
116 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))]
117 #[cfg_attr(feature = "full", diesel(table_name = person_follower))]
118 pub struct PersonFollower {
120 pub person_id: PersonId,
121 pub follower_id: PersonId,
122 pub published: chrono::NaiveDateTime,
127 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
128 #[cfg_attr(feature = "full", diesel(table_name = person_follower))]
129 pub struct PersonFollowerForm {
130 pub person_id: PersonId,
131 pub follower_id: PersonId,