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