1 #[cfg(feature = "full")]
2 use crate::schema::local_user;
4 newtypes::{LocalUserId, PersonId},
8 use serde::{Deserialize, Serialize};
9 use typed_builder::TypedBuilder;
11 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
12 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
13 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
14 pub struct LocalUser {
16 pub person_id: PersonId,
18 pub password_encrypted: String,
19 pub email: Option<String>,
22 pub default_sort_type: SortType,
23 pub default_listing_type: ListingType,
24 pub interface_language: String,
25 pub show_avatars: bool,
26 pub send_notifications_to_email: bool,
27 pub validator_time: chrono::NaiveDateTime,
28 pub show_scores: bool,
29 pub show_bot_accounts: bool,
30 pub show_read_posts: bool,
31 pub show_new_post_notifs: bool,
32 pub email_verified: bool,
33 pub accepted_application: bool,
35 pub totp_2fa_secret: Option<String>,
36 pub totp_2fa_url: Option<String>,
39 #[derive(Clone, TypedBuilder)]
40 #[builder(field_defaults(default))]
41 #[cfg_attr(feature = "full", derive(Insertable))]
42 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
43 pub struct LocalUserInsertForm {
45 pub person_id: PersonId,
47 pub password_encrypted: String,
48 pub email: Option<String>,
49 pub show_nsfw: Option<bool>,
50 pub theme: Option<String>,
51 pub default_sort_type: Option<SortType>,
52 pub default_listing_type: Option<ListingType>,
53 pub interface_language: Option<String>,
54 pub show_avatars: Option<bool>,
55 pub send_notifications_to_email: Option<bool>,
56 pub show_bot_accounts: Option<bool>,
57 pub show_scores: Option<bool>,
58 pub show_read_posts: Option<bool>,
59 pub show_new_post_notifs: Option<bool>,
60 pub email_verified: Option<bool>,
61 pub accepted_application: Option<bool>,
62 pub totp_2fa_secret: Option<Option<String>>,
63 pub totp_2fa_url: Option<Option<String>>,
66 #[derive(Clone, TypedBuilder)]
67 #[builder(field_defaults(default))]
68 #[cfg_attr(feature = "full", derive(AsChangeset))]
69 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
70 pub struct LocalUserUpdateForm {
71 pub password_encrypted: Option<String>,
72 pub email: Option<Option<String>>,
73 pub show_nsfw: Option<bool>,
74 pub theme: Option<String>,
75 pub default_sort_type: Option<SortType>,
76 pub default_listing_type: Option<ListingType>,
77 pub interface_language: Option<String>,
78 pub show_avatars: Option<bool>,
79 pub send_notifications_to_email: Option<bool>,
80 pub show_bot_accounts: Option<bool>,
81 pub show_scores: Option<bool>,
82 pub show_read_posts: Option<bool>,
83 pub show_new_post_notifs: Option<bool>,
84 pub email_verified: Option<bool>,
85 pub accepted_application: Option<bool>,
86 pub totp_2fa_secret: Option<Option<String>>,
87 pub totp_2fa_url: Option<Option<String>>,