]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/local_user.rs
Group imports dess (#2526)
[lemmy.git] / crates / db_schema / src / source / local_user.rs
1 use crate::newtypes::{LocalUserId, PersonId};
2 #[cfg(feature = "full")]
3 use crate::schema::local_user;
4 use serde::{Deserialize, Serialize};
5 use typed_builder::TypedBuilder;
6
7 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", diesel(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 interface_language: 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 /// A local user view that removes password encrypted
32 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
33 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
34 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
35 pub struct LocalUserSettings {
36   pub id: LocalUserId,
37   pub person_id: PersonId,
38   pub email: Option<String>,
39   pub show_nsfw: bool,
40   pub theme: String,
41   pub default_sort_type: i16,
42   pub default_listing_type: i16,
43   pub interface_language: String,
44   pub show_avatars: bool,
45   pub send_notifications_to_email: bool,
46   pub validator_time: chrono::NaiveDateTime,
47   pub show_bot_accounts: bool,
48   pub show_scores: bool,
49   pub show_read_posts: bool,
50   pub show_new_post_notifs: bool,
51   pub email_verified: bool,
52   pub accepted_application: bool,
53 }
54
55 #[derive(Clone, TypedBuilder)]
56 #[builder(field_defaults(default))]
57 #[cfg_attr(feature = "full", derive(Insertable))]
58 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
59 pub struct LocalUserInsertForm {
60   #[builder(!default)]
61   pub person_id: PersonId,
62   #[builder(!default)]
63   pub password_encrypted: String,
64   pub email: Option<String>,
65   pub show_nsfw: Option<bool>,
66   pub theme: Option<String>,
67   pub default_sort_type: Option<i16>,
68   pub default_listing_type: Option<i16>,
69   pub interface_language: Option<String>,
70   pub show_avatars: Option<bool>,
71   pub send_notifications_to_email: Option<bool>,
72   pub show_bot_accounts: Option<bool>,
73   pub show_scores: Option<bool>,
74   pub show_read_posts: Option<bool>,
75   pub show_new_post_notifs: Option<bool>,
76   pub email_verified: Option<bool>,
77   pub accepted_application: Option<bool>,
78 }
79
80 #[derive(Clone, TypedBuilder)]
81 #[builder(field_defaults(default))]
82 #[cfg_attr(feature = "full", derive(AsChangeset))]
83 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
84 pub struct LocalUserUpdateForm {
85   pub password_encrypted: Option<String>,
86   pub email: Option<Option<String>>,
87   pub show_nsfw: Option<bool>,
88   pub theme: Option<String>,
89   pub default_sort_type: Option<i16>,
90   pub default_listing_type: Option<i16>,
91   pub interface_language: Option<String>,
92   pub show_avatars: Option<bool>,
93   pub send_notifications_to_email: Option<bool>,
94   pub show_bot_accounts: Option<bool>,
95   pub show_scores: Option<bool>,
96   pub show_read_posts: Option<bool>,
97   pub show_new_post_notifs: Option<bool>,
98   pub email_verified: Option<bool>,
99   pub accepted_application: Option<bool>,
100 }