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