]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/local_user.rs
11dac6c9c06706c05948931c2c0047caa3c2c8da
[lemmy.git] / crates / db_schema / src / source / local_user.rs
1 use crate::{schema::local_user, LocalUserId, PersonId};
2 use serde::Serialize;
3
4 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
5 #[table_name = "local_user"]
6 pub struct LocalUser {
7   pub id: LocalUserId,
8   pub person_id: PersonId,
9   pub password_encrypted: String,
10   pub email: Option<String>,
11   pub admin: bool,
12   pub show_nsfw: bool,
13   pub theme: String,
14   pub default_sort_type: i16,
15   pub default_listing_type: i16,
16   pub lang: String,
17   pub show_avatars: bool,
18   pub send_notifications_to_email: bool,
19   pub matrix_user_id: Option<String>,
20   pub validator_time: chrono::NaiveDateTime,
21 }
22
23 // TODO redo these, check table defaults
24 #[derive(Insertable, AsChangeset, Clone)]
25 #[table_name = "local_user"]
26 pub struct LocalUserForm {
27   pub person_id: PersonId,
28   pub password_encrypted: String,
29   pub email: Option<Option<String>>,
30   pub admin: Option<bool>,
31   pub show_nsfw: Option<bool>,
32   pub theme: Option<String>,
33   pub default_sort_type: Option<i16>,
34   pub default_listing_type: Option<i16>,
35   pub lang: Option<String>,
36   pub show_avatars: Option<bool>,
37   pub send_notifications_to_email: Option<bool>,
38   pub matrix_user_id: Option<Option<String>>,
39 }
40
41 /// A local user view that removes password encrypted
42 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
43 #[table_name = "local_user"]
44 pub struct LocalUserSettings {
45   pub id: LocalUserId,
46   pub person_id: PersonId,
47   pub email: Option<String>,
48   pub admin: bool,
49   pub show_nsfw: bool,
50   pub theme: String,
51   pub default_sort_type: i16,
52   pub default_listing_type: i16,
53   pub lang: String,
54   pub show_avatars: bool,
55   pub send_notifications_to_email: bool,
56   pub matrix_user_id: Option<String>,
57   pub validator_time: chrono::NaiveDateTime,
58 }