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