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;
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 {
12 pub person_id: PersonId,
14 pub password_encrypted: String,
15 pub email: Option<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,
31 pub totp_2fa_secret: Option<String>,
32 pub totp_2fa_url: Option<String>,
35 #[derive(Clone, TypedBuilder)]
36 #[builder(field_defaults(default))]
37 #[cfg_attr(feature = "full", derive(Insertable))]
38 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
39 pub struct LocalUserInsertForm {
41 pub person_id: PersonId,
43 pub password_encrypted: String,
44 pub email: Option<String>,
45 pub show_nsfw: Option<bool>,
46 pub theme: Option<String>,
47 pub default_sort_type: Option<i16>,
48 pub default_listing_type: Option<i16>,
49 pub interface_language: Option<String>,
50 pub show_avatars: Option<bool>,
51 pub send_notifications_to_email: Option<bool>,
52 pub show_bot_accounts: Option<bool>,
53 pub show_scores: Option<bool>,
54 pub show_read_posts: Option<bool>,
55 pub show_new_post_notifs: Option<bool>,
56 pub email_verified: Option<bool>,
57 pub accepted_application: Option<bool>,
58 pub totp_2fa_secret: Option<Option<String>>,
59 pub totp_2fa_url: Option<Option<String>>,
62 #[derive(Clone, TypedBuilder)]
63 #[builder(field_defaults(default))]
64 #[cfg_attr(feature = "full", derive(AsChangeset))]
65 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
66 pub struct LocalUserUpdateForm {
67 pub password_encrypted: Option<String>,
68 pub email: Option<Option<String>>,
69 pub show_nsfw: Option<bool>,
70 pub theme: Option<String>,
71 pub default_sort_type: Option<i16>,
72 pub default_listing_type: Option<i16>,
73 pub interface_language: Option<String>,
74 pub show_avatars: Option<bool>,
75 pub send_notifications_to_email: Option<bool>,
76 pub show_bot_accounts: Option<bool>,
77 pub show_scores: Option<bool>,
78 pub show_read_posts: Option<bool>,
79 pub show_new_post_notifs: Option<bool>,
80 pub email_verified: Option<bool>,
81 pub accepted_application: Option<bool>,
82 pub totp_2fa_secret: Option<Option<String>>,
83 pub totp_2fa_url: Option<Option<String>>,