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