]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/person.rs
e4888ddbf576b5f689cbddfca596724524acf0b0
[lemmy.git] / crates / db_schema / src / source / person.rs
1 use crate::newtypes::{DbUrl, PersonId};
2 use serde::{Deserialize, Serialize};
3
4 #[cfg(feature = "full")]
5 use crate::schema::{person, person_alias_1, person_alias_2};
6
7 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", table_name = "person")]
10 pub struct Person {
11   pub id: PersonId,
12   pub name: String,
13   pub display_name: Option<String>,
14   pub avatar: Option<DbUrl>,
15   pub banned: bool,
16   pub published: chrono::NaiveDateTime,
17   pub updated: Option<chrono::NaiveDateTime>,
18   pub actor_id: DbUrl,
19   pub bio: Option<String>,
20   pub local: bool,
21   pub private_key: Option<String>,
22   pub public_key: String,
23   pub last_refreshed_at: chrono::NaiveDateTime,
24   pub banner: Option<DbUrl>,
25   pub deleted: bool,
26   pub inbox_url: DbUrl,
27   pub shared_inbox_url: Option<DbUrl>,
28   pub matrix_user_id: Option<String>,
29   pub admin: bool,
30   pub bot_account: bool,
31   pub ban_expires: Option<chrono::NaiveDateTime>,
32 }
33
34 /// A safe representation of person, without the sensitive info
35 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
36 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
37 #[cfg_attr(feature = "full", table_name = "person")]
38 pub struct PersonSafe {
39   pub id: PersonId,
40   pub name: String,
41   pub display_name: Option<String>,
42   pub avatar: Option<DbUrl>,
43   pub banned: bool,
44   pub published: chrono::NaiveDateTime,
45   pub updated: Option<chrono::NaiveDateTime>,
46   pub actor_id: DbUrl,
47   pub bio: Option<String>,
48   pub local: bool,
49   pub banner: Option<DbUrl>,
50   pub deleted: bool,
51   pub inbox_url: DbUrl,
52   pub shared_inbox_url: Option<DbUrl>,
53   pub matrix_user_id: Option<String>,
54   pub admin: bool,
55   pub bot_account: bool,
56   pub ban_expires: Option<chrono::NaiveDateTime>,
57 }
58
59 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
60 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
61 #[cfg_attr(feature = "full", table_name = "person_alias_1")]
62 pub struct PersonAlias1 {
63   pub id: PersonId,
64   pub name: String,
65   pub display_name: Option<String>,
66   pub avatar: Option<DbUrl>,
67   pub banned: bool,
68   pub published: chrono::NaiveDateTime,
69   pub updated: Option<chrono::NaiveDateTime>,
70   pub actor_id: DbUrl,
71   pub bio: Option<String>,
72   pub local: bool,
73   pub private_key: Option<String>,
74   pub public_key: String,
75   pub last_refreshed_at: chrono::NaiveDateTime,
76   pub banner: Option<DbUrl>,
77   pub deleted: bool,
78   pub inbox_url: DbUrl,
79   pub shared_inbox_url: Option<DbUrl>,
80   pub matrix_user_id: Option<String>,
81   pub admin: bool,
82   pub bot_account: bool,
83   pub ban_expires: Option<chrono::NaiveDateTime>,
84 }
85
86 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
87 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
88 #[cfg_attr(feature = "full", table_name = "person_alias_1")]
89 pub struct PersonSafeAlias1 {
90   pub id: PersonId,
91   pub name: String,
92   pub display_name: Option<String>,
93   pub avatar: Option<DbUrl>,
94   pub banned: bool,
95   pub published: chrono::NaiveDateTime,
96   pub updated: Option<chrono::NaiveDateTime>,
97   pub actor_id: DbUrl,
98   pub bio: Option<String>,
99   pub local: bool,
100   pub banner: Option<DbUrl>,
101   pub deleted: bool,
102   pub inbox_url: DbUrl,
103   pub shared_inbox_url: Option<DbUrl>,
104   pub matrix_user_id: Option<String>,
105   pub admin: bool,
106   pub bot_account: bool,
107   pub ban_expires: Option<chrono::NaiveDateTime>,
108 }
109
110 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
111 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
112 #[cfg_attr(feature = "full", table_name = "person_alias_2")]
113 pub struct PersonAlias2 {
114   pub id: PersonId,
115   pub name: String,
116   pub display_name: Option<String>,
117   pub avatar: Option<DbUrl>,
118   pub banned: bool,
119   pub published: chrono::NaiveDateTime,
120   pub updated: Option<chrono::NaiveDateTime>,
121   pub actor_id: DbUrl,
122   pub bio: Option<String>,
123   pub local: bool,
124   pub private_key: Option<String>,
125   pub public_key: String,
126   pub last_refreshed_at: chrono::NaiveDateTime,
127   pub banner: Option<DbUrl>,
128   pub deleted: bool,
129   pub inbox_url: DbUrl,
130   pub shared_inbox_url: Option<DbUrl>,
131   pub matrix_user_id: Option<String>,
132   pub admin: bool,
133   pub bot_account: bool,
134   pub ban_expires: Option<chrono::NaiveDateTime>,
135 }
136
137 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
138 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
139 #[cfg_attr(feature = "full", table_name = "person_alias_1")]
140 pub struct PersonSafeAlias2 {
141   pub id: PersonId,
142   pub name: String,
143   pub display_name: Option<String>,
144   pub avatar: Option<DbUrl>,
145   pub banned: bool,
146   pub published: chrono::NaiveDateTime,
147   pub updated: Option<chrono::NaiveDateTime>,
148   pub actor_id: DbUrl,
149   pub bio: Option<String>,
150   pub local: bool,
151   pub banner: Option<DbUrl>,
152   pub deleted: bool,
153   pub inbox_url: DbUrl,
154   pub shared_inbox_url: Option<DbUrl>,
155   pub matrix_user_id: Option<String>,
156   pub admin: bool,
157   pub bot_account: bool,
158   pub ban_expires: Option<chrono::NaiveDateTime>,
159 }
160
161 #[derive(Clone, Default)]
162 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
163 #[cfg_attr(feature = "full", table_name = "person")]
164 pub struct PersonForm {
165   pub name: String,
166   pub display_name: Option<Option<String>>,
167   pub avatar: Option<Option<DbUrl>>,
168   pub banned: Option<bool>,
169   pub published: Option<chrono::NaiveDateTime>,
170   pub updated: Option<chrono::NaiveDateTime>,
171   pub actor_id: Option<DbUrl>,
172   pub bio: Option<Option<String>>,
173   pub local: Option<bool>,
174   pub private_key: Option<Option<String>>,
175   pub public_key: Option<String>,
176   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
177   pub banner: Option<Option<DbUrl>>,
178   pub deleted: Option<bool>,
179   pub inbox_url: Option<DbUrl>,
180   pub shared_inbox_url: Option<Option<DbUrl>>,
181   pub matrix_user_id: Option<Option<String>>,
182   pub admin: Option<bool>,
183   pub bot_account: Option<bool>,
184   pub ban_expires: Option<Option<chrono::NaiveDateTime>>,
185 }