]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/local_user.rs
c38a5ac640558e6047532a1d502345dcdd18dace
[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   #[serde(skip)]
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 #[derive(Clone, TypedBuilder)]
33 #[builder(field_defaults(default))]
34 #[cfg_attr(feature = "full", derive(Insertable))]
35 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
36 pub struct LocalUserInsertForm {
37   #[builder(!default)]
38   pub person_id: PersonId,
39   #[builder(!default)]
40   pub password_encrypted: String,
41   pub email: Option<String>,
42   pub show_nsfw: Option<bool>,
43   pub theme: Option<String>,
44   pub default_sort_type: Option<i16>,
45   pub default_listing_type: Option<i16>,
46   pub interface_language: Option<String>,
47   pub show_avatars: Option<bool>,
48   pub send_notifications_to_email: Option<bool>,
49   pub show_bot_accounts: Option<bool>,
50   pub show_scores: Option<bool>,
51   pub show_read_posts: Option<bool>,
52   pub show_new_post_notifs: Option<bool>,
53   pub email_verified: Option<bool>,
54   pub accepted_application: Option<bool>,
55 }
56
57 #[derive(Clone, TypedBuilder)]
58 #[builder(field_defaults(default))]
59 #[cfg_attr(feature = "full", derive(AsChangeset))]
60 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
61 pub struct LocalUserUpdateForm {
62   pub password_encrypted: Option<String>,
63   pub email: Option<Option<String>>,
64   pub show_nsfw: Option<bool>,
65   pub theme: Option<String>,
66   pub default_sort_type: Option<i16>,
67   pub default_listing_type: Option<i16>,
68   pub interface_language: Option<String>,
69   pub show_avatars: Option<bool>,
70   pub send_notifications_to_email: Option<bool>,
71   pub show_bot_accounts: Option<bool>,
72   pub show_scores: Option<bool>,
73   pub show_read_posts: Option<bool>,
74   pub show_new_post_notifs: Option<bool>,
75   pub email_verified: Option<bool>,
76   pub accepted_application: Option<bool>,
77 }