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