]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/local_user.rs
Add infinite scroll user option (#3572)
[lemmy.git] / crates / db_schema / src / source / local_user.rs
1 #[cfg(feature = "full")]
2 use crate::schema::local_user;
3 use crate::{
4   newtypes::{LocalUserId, PersonId},
5   ListingType,
6   SortType,
7 };
8 use serde::{Deserialize, Serialize};
9 use serde_with::skip_serializing_none;
10 #[cfg(feature = "full")]
11 use ts_rs::TS;
12 use typed_builder::TypedBuilder;
13
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 /// A local user.
20 pub struct LocalUser {
21   pub id: LocalUserId,
22   /// The person_id for the local user.
23   pub person_id: PersonId,
24   #[serde(skip)]
25   pub password_encrypted: String,
26   pub email: Option<String>,
27   /// Whether to show NSFW content.
28   pub show_nsfw: bool,
29   pub theme: String,
30   pub default_sort_type: SortType,
31   pub default_listing_type: ListingType,
32   pub interface_language: String,
33   /// Whether to show avatars.
34   pub show_avatars: bool,
35   pub send_notifications_to_email: bool,
36   /// A validation ID used in logging out sessions.
37   pub validator_time: chrono::NaiveDateTime,
38   /// Whether to show comment / post scores.
39   pub show_scores: bool,
40   /// Whether to show bot accounts.
41   pub show_bot_accounts: bool,
42   /// Whether to show read posts.
43   pub show_read_posts: bool,
44   /// Whether to show new posts as notifications.
45   pub show_new_post_notifs: bool,
46   /// Whether their email has been verified.
47   pub email_verified: bool,
48   /// Whether their registration application has been accepted.
49   pub accepted_application: bool,
50   #[serde(skip)]
51   pub totp_2fa_secret: Option<String>,
52   /// A URL to add their 2-factor auth.
53   pub totp_2fa_url: Option<String>,
54   /// Open links in a new tab.
55   pub open_links_in_new_tab: bool,
56   /// Whether infinite scroll is enabled.
57   pub infinite_scroll_enabled: bool,
58 }
59
60 #[derive(Clone, TypedBuilder)]
61 #[builder(field_defaults(default))]
62 #[cfg_attr(feature = "full", derive(Insertable))]
63 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
64 pub struct LocalUserInsertForm {
65   #[builder(!default)]
66   pub person_id: PersonId,
67   #[builder(!default)]
68   pub password_encrypted: String,
69   pub email: Option<String>,
70   pub show_nsfw: Option<bool>,
71   pub theme: Option<String>,
72   pub default_sort_type: Option<SortType>,
73   pub default_listing_type: Option<ListingType>,
74   pub interface_language: Option<String>,
75   pub show_avatars: Option<bool>,
76   pub send_notifications_to_email: Option<bool>,
77   pub show_bot_accounts: Option<bool>,
78   pub show_scores: Option<bool>,
79   pub show_read_posts: Option<bool>,
80   pub show_new_post_notifs: Option<bool>,
81   pub email_verified: Option<bool>,
82   pub accepted_application: Option<bool>,
83   pub totp_2fa_secret: Option<Option<String>>,
84   pub totp_2fa_url: Option<Option<String>>,
85   pub open_links_in_new_tab: Option<bool>,
86   pub infinite_scroll_enabled: Option<bool>,
87 }
88
89 #[derive(Clone, TypedBuilder)]
90 #[builder(field_defaults(default))]
91 #[cfg_attr(feature = "full", derive(AsChangeset))]
92 #[cfg_attr(feature = "full", diesel(table_name = local_user))]
93 pub struct LocalUserUpdateForm {
94   pub password_encrypted: Option<String>,
95   pub email: Option<Option<String>>,
96   pub show_nsfw: Option<bool>,
97   pub theme: Option<String>,
98   pub default_sort_type: Option<SortType>,
99   pub default_listing_type: Option<ListingType>,
100   pub interface_language: Option<String>,
101   pub show_avatars: Option<bool>,
102   pub send_notifications_to_email: Option<bool>,
103   pub show_bot_accounts: Option<bool>,
104   pub show_scores: Option<bool>,
105   pub show_read_posts: Option<bool>,
106   pub show_new_post_notifs: Option<bool>,
107   pub email_verified: Option<bool>,
108   pub accepted_application: Option<bool>,
109   pub totp_2fa_secret: Option<Option<String>>,
110   pub totp_2fa_url: Option<Option<String>>,
111   pub open_links_in_new_tab: Option<bool>,
112   pub infinite_scroll_enabled: Option<bool>,
113 }