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