1 use crate::newtypes::{LocalUserId, PersonId};
2 use serde::{Deserialize, Serialize};
4 #[cfg(feature = "full")]
5 use crate::schema::local_user;
7 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", table_name = "local_user")]
10 pub struct LocalUser {
12 pub person_id: PersonId,
13 pub password_encrypted: String,
14 pub email: Option<String>,
17 pub default_sort_type: i16,
18 pub default_listing_type: i16,
20 pub show_avatars: bool,
21 pub send_notifications_to_email: bool,
22 pub validator_time: chrono::NaiveDateTime,
23 pub show_bot_accounts: bool,
24 pub show_scores: bool,
25 pub show_read_posts: bool,
26 pub show_new_post_notifs: bool,
27 pub email_verified: bool,
28 pub accepted_application: bool,
31 // TODO redo these, check table defaults
32 #[derive(Clone, Default)]
33 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
34 #[cfg_attr(feature = "full", table_name = "local_user")]
35 pub struct LocalUserForm {
36 pub person_id: Option<PersonId>,
37 pub password_encrypted: Option<String>,
38 pub email: Option<Option<String>>,
39 pub show_nsfw: Option<bool>,
40 pub theme: Option<String>,
41 pub default_sort_type: Option<i16>,
42 pub default_listing_type: Option<i16>,
43 pub lang: Option<String>,
44 pub show_avatars: Option<bool>,
45 pub send_notifications_to_email: Option<bool>,
46 pub show_bot_accounts: Option<bool>,
47 pub show_scores: Option<bool>,
48 pub show_read_posts: Option<bool>,
49 pub show_new_post_notifs: Option<bool>,
50 pub email_verified: Option<bool>,
51 pub accepted_application: Option<bool>,
54 /// A local user view that removes password encrypted
55 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
56 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
57 #[cfg_attr(feature = "full", table_name = "local_user")]
58 pub struct LocalUserSettings {
60 pub person_id: PersonId,
61 pub email: Option<String>,
64 pub default_sort_type: i16,
65 pub default_listing_type: i16,
67 pub show_avatars: bool,
68 pub send_notifications_to_email: bool,
69 pub validator_time: chrono::NaiveDateTime,
70 pub show_bot_accounts: bool,
71 pub show_scores: bool,
72 pub show_read_posts: bool,
73 pub show_new_post_notifs: bool,
74 pub email_verified: bool,
75 pub accepted_application: bool,