1 use crate::newtypes::{DbUrl, InstanceId, PersonId};
2 use serde::{Deserialize, Serialize};
3 use typed_builder::TypedBuilder;
5 #[cfg(feature = "full")]
6 use crate::schema::person;
8 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
9 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
10 #[cfg_attr(feature = "full", diesel(table_name = person))]
14 pub display_name: Option<String>,
15 pub avatar: Option<DbUrl>,
17 pub published: chrono::NaiveDateTime,
18 pub updated: Option<chrono::NaiveDateTime>,
20 pub bio: Option<String>,
22 pub private_key: Option<String>,
23 pub public_key: String,
24 pub last_refreshed_at: chrono::NaiveDateTime,
25 pub banner: Option<DbUrl>,
28 pub shared_inbox_url: Option<DbUrl>,
29 pub matrix_user_id: Option<String>,
31 pub bot_account: bool,
32 pub ban_expires: Option<chrono::NaiveDateTime>,
33 pub instance_id: InstanceId,
36 /// A safe representation of person, without the sensitive info
37 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
38 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
39 #[cfg_attr(feature = "full", diesel(table_name = person))]
40 pub struct PersonSafe {
43 pub display_name: Option<String>,
44 pub avatar: Option<DbUrl>,
46 pub published: chrono::NaiveDateTime,
47 pub updated: Option<chrono::NaiveDateTime>,
49 pub bio: Option<String>,
51 pub banner: Option<DbUrl>,
54 pub shared_inbox_url: Option<DbUrl>,
55 pub matrix_user_id: Option<String>,
57 pub bot_account: bool,
58 pub ban_expires: Option<chrono::NaiveDateTime>,
59 pub instance_id: InstanceId,
62 #[derive(Clone, TypedBuilder)]
63 #[builder(field_defaults(default))]
64 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
65 #[cfg_attr(feature = "full", diesel(table_name = person))]
66 pub struct PersonInsertForm {
70 pub public_key: String,
72 pub instance_id: InstanceId,
73 pub display_name: Option<String>,
74 pub avatar: Option<DbUrl>,
75 pub banned: Option<bool>,
76 pub published: Option<chrono::NaiveDateTime>,
77 pub updated: Option<chrono::NaiveDateTime>,
78 pub actor_id: Option<DbUrl>,
79 pub bio: Option<String>,
80 pub local: Option<bool>,
81 pub private_key: Option<String>,
82 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
83 pub banner: Option<DbUrl>,
84 pub deleted: Option<bool>,
85 pub inbox_url: Option<DbUrl>,
86 pub shared_inbox_url: Option<DbUrl>,
87 pub matrix_user_id: Option<String>,
88 pub admin: Option<bool>,
89 pub bot_account: Option<bool>,
90 pub ban_expires: Option<chrono::NaiveDateTime>,
93 #[derive(Clone, TypedBuilder)]
94 #[cfg_attr(feature = "full", derive(AsChangeset))]
95 #[cfg_attr(feature = "full", diesel(table_name = person))]
96 #[builder(field_defaults(default))]
97 pub struct PersonUpdateForm {
98 pub display_name: Option<Option<String>>,
99 pub avatar: Option<Option<DbUrl>>,
100 pub banned: Option<bool>,
101 pub updated: Option<Option<chrono::NaiveDateTime>>,
102 pub actor_id: Option<DbUrl>,
103 pub bio: Option<Option<String>>,
104 pub local: Option<bool>,
105 pub public_key: Option<String>,
106 pub private_key: Option<Option<String>>,
107 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
108 pub banner: Option<Option<DbUrl>>,
109 pub deleted: Option<bool>,
110 pub inbox_url: Option<DbUrl>,
111 pub shared_inbox_url: Option<Option<DbUrl>>,
112 pub matrix_user_id: Option<Option<String>>,
113 pub admin: Option<bool>,
114 pub bot_account: Option<bool>,
115 pub ban_expires: Option<Option<chrono::NaiveDateTime>>,