]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/local_user.rs
df83e268feb104f27ce9f7d66c73c049c4693bec
[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 show_nsfw: bool,
12   pub theme: String,
13   pub default_sort_type: i16,
14   pub default_listing_type: i16,
15   pub lang: String,
16   pub show_avatars: bool,
17   pub send_notifications_to_email: bool,
18   pub validator_time: chrono::NaiveDateTime,
19   pub show_bot_accounts: bool,
20   pub show_scores: bool,
21   pub show_read_posts: bool,
22   pub show_new_post_notifs: bool,
23 }
24
25 // TODO redo these, check table defaults
26 #[derive(Insertable, AsChangeset, Clone, Default)]
27 #[table_name = "local_user"]
28 pub struct LocalUserForm {
29   pub person_id: PersonId,
30   pub password_encrypted: String,
31   pub email: Option<Option<String>>,
32   pub show_nsfw: Option<bool>,
33   pub theme: Option<String>,
34   pub default_sort_type: Option<i16>,
35   pub default_listing_type: Option<i16>,
36   pub lang: Option<String>,
37   pub show_avatars: Option<bool>,
38   pub send_notifications_to_email: Option<bool>,
39   pub show_bot_accounts: Option<bool>,
40   pub show_scores: Option<bool>,
41   pub show_read_posts: Option<bool>,
42   pub show_new_post_notifs: Option<bool>,
43 }
44
45 /// A local user view that removes password encrypted
46 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
47 #[table_name = "local_user"]
48 pub struct LocalUserSettings {
49   pub id: LocalUserId,
50   pub person_id: PersonId,
51   pub email: Option<String>,
52   pub show_nsfw: bool,
53   pub theme: String,
54   pub default_sort_type: i16,
55   pub default_listing_type: i16,
56   pub lang: String,
57   pub show_avatars: bool,
58   pub send_notifications_to_email: bool,
59   pub validator_time: chrono::NaiveDateTime,
60   pub show_bot_accounts: bool,
61   pub show_scores: bool,
62   pub show_read_posts: bool,
63   pub show_new_post_notifs: bool,
64 }