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