]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/user.rs
d72929fa8ec2be08ebf8ad68c32192787b040c52
[lemmy.git] / crates / db_schema / src / source / user.rs
1 use crate::{
2   schema::{user_, user_alias_1, user_alias_2},
3   Url,
4 };
5 use serde::Serialize;
6
7 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
8 #[table_name = "user_"]
9 pub struct User_ {
10   pub id: i32,
11   pub name: String,
12   pub preferred_username: Option<String>,
13   pub password_encrypted: String,
14   pub email: Option<String>,
15   pub avatar: Option<String>,
16   pub admin: bool,
17   pub banned: bool,
18   pub published: chrono::NaiveDateTime,
19   pub updated: Option<chrono::NaiveDateTime>,
20   pub show_nsfw: bool,
21   pub theme: String,
22   pub default_sort_type: i16,
23   pub default_listing_type: i16,
24   pub lang: String,
25   pub show_avatars: bool,
26   pub send_notifications_to_email: bool,
27   pub matrix_user_id: Option<String>,
28   pub actor_id: Url,
29   pub bio: Option<String>,
30   pub local: bool,
31   pub private_key: Option<String>,
32   pub public_key: Option<String>,
33   pub last_refreshed_at: chrono::NaiveDateTime,
34   pub banner: Option<String>,
35   pub deleted: bool,
36   pub inbox_url: Url,
37   pub shared_inbox_url: Option<Url>,
38 }
39
40 /// A safe representation of user, without the sensitive info
41 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
42 #[table_name = "user_"]
43 pub struct UserSafe {
44   pub id: i32,
45   pub name: String,
46   pub preferred_username: Option<String>,
47   pub avatar: Option<String>,
48   pub admin: bool,
49   pub banned: bool,
50   pub published: chrono::NaiveDateTime,
51   pub updated: Option<chrono::NaiveDateTime>,
52   pub matrix_user_id: Option<String>,
53   pub actor_id: Url,
54   pub bio: Option<String>,
55   pub local: bool,
56   pub banner: Option<String>,
57   pub deleted: bool,
58   pub inbox_url: Url,
59   pub shared_inbox_url: Option<Url>,
60 }
61
62 /// A safe user view with only settings
63 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
64 #[table_name = "user_"]
65 pub struct UserSafeSettings {
66   pub id: i32,
67   pub name: String,
68   pub preferred_username: Option<String>,
69   pub email: Option<String>,
70   pub avatar: Option<String>,
71   pub admin: bool,
72   pub banned: bool,
73   pub published: chrono::NaiveDateTime,
74   pub updated: Option<chrono::NaiveDateTime>,
75   pub show_nsfw: bool,
76   pub theme: String,
77   pub default_sort_type: i16,
78   pub default_listing_type: i16,
79   pub lang: String,
80   pub show_avatars: bool,
81   pub send_notifications_to_email: bool,
82   pub matrix_user_id: Option<String>,
83   pub actor_id: Url,
84   pub bio: Option<String>,
85   pub local: bool,
86   pub last_refreshed_at: chrono::NaiveDateTime,
87   pub banner: Option<String>,
88   pub deleted: bool,
89 }
90
91 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
92 #[table_name = "user_alias_1"]
93 pub struct UserAlias1 {
94   pub id: i32,
95   pub name: String,
96   pub preferred_username: Option<String>,
97   pub password_encrypted: String,
98   pub email: Option<String>,
99   pub avatar: Option<String>,
100   pub admin: bool,
101   pub banned: bool,
102   pub published: chrono::NaiveDateTime,
103   pub updated: Option<chrono::NaiveDateTime>,
104   pub show_nsfw: bool,
105   pub theme: String,
106   pub default_sort_type: i16,
107   pub default_listing_type: i16,
108   pub lang: String,
109   pub show_avatars: bool,
110   pub send_notifications_to_email: bool,
111   pub matrix_user_id: Option<String>,
112   pub actor_id: Url,
113   pub bio: Option<String>,
114   pub local: bool,
115   pub private_key: Option<String>,
116   pub public_key: Option<String>,
117   pub last_refreshed_at: chrono::NaiveDateTime,
118   pub banner: Option<String>,
119   pub deleted: bool,
120 }
121
122 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
123 #[table_name = "user_alias_1"]
124 pub struct UserSafeAlias1 {
125   pub id: i32,
126   pub name: String,
127   pub preferred_username: Option<String>,
128   pub avatar: Option<String>,
129   pub admin: bool,
130   pub banned: bool,
131   pub published: chrono::NaiveDateTime,
132   pub updated: Option<chrono::NaiveDateTime>,
133   pub matrix_user_id: Option<String>,
134   pub actor_id: Url,
135   pub bio: Option<String>,
136   pub local: bool,
137   pub banner: Option<String>,
138   pub deleted: bool,
139 }
140
141 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
142 #[table_name = "user_alias_2"]
143 pub struct UserAlias2 {
144   pub id: i32,
145   pub name: String,
146   pub preferred_username: Option<String>,
147   pub password_encrypted: String,
148   pub email: Option<String>,
149   pub avatar: Option<String>,
150   pub admin: bool,
151   pub banned: bool,
152   pub published: chrono::NaiveDateTime,
153   pub updated: Option<chrono::NaiveDateTime>,
154   pub show_nsfw: bool,
155   pub theme: String,
156   pub default_sort_type: i16,
157   pub default_listing_type: i16,
158   pub lang: String,
159   pub show_avatars: bool,
160   pub send_notifications_to_email: bool,
161   pub matrix_user_id: Option<String>,
162   pub actor_id: Url,
163   pub bio: Option<String>,
164   pub local: bool,
165   pub private_key: Option<String>,
166   pub public_key: Option<String>,
167   pub last_refreshed_at: chrono::NaiveDateTime,
168   pub banner: Option<String>,
169   pub deleted: bool,
170 }
171
172 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
173 #[table_name = "user_alias_2"]
174 pub struct UserSafeAlias2 {
175   pub id: i32,
176   pub name: String,
177   pub preferred_username: Option<String>,
178   pub avatar: Option<String>,
179   pub admin: bool,
180   pub banned: bool,
181   pub published: chrono::NaiveDateTime,
182   pub updated: Option<chrono::NaiveDateTime>,
183   pub matrix_user_id: Option<String>,
184   pub actor_id: Url,
185   pub bio: Option<String>,
186   pub local: bool,
187   pub banner: Option<String>,
188   pub deleted: bool,
189 }
190
191 #[derive(Insertable, AsChangeset, Clone)]
192 #[table_name = "user_"]
193 pub struct UserForm {
194   pub name: String,
195   pub preferred_username: Option<Option<String>>,
196   pub password_encrypted: String,
197   pub admin: bool,
198   pub banned: Option<bool>,
199   pub email: Option<Option<String>>,
200   pub avatar: Option<Option<String>>,
201   pub published: Option<chrono::NaiveDateTime>,
202   pub updated: Option<chrono::NaiveDateTime>,
203   pub show_nsfw: bool,
204   pub theme: String,
205   pub default_sort_type: i16,
206   pub default_listing_type: i16,
207   pub lang: String,
208   pub show_avatars: bool,
209   pub send_notifications_to_email: bool,
210   pub matrix_user_id: Option<Option<String>>,
211   pub actor_id: Option<Url>,
212   pub bio: Option<Option<String>>,
213   pub local: bool,
214   pub private_key: Option<String>,
215   pub public_key: Option<String>,
216   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
217   pub banner: Option<Option<String>>,
218   pub inbox_url: Option<Url>,
219   pub shared_inbox_url: Option<Option<Url>>,
220 }