]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/local_user.rs
Adding typescript generation for API. Fixes #2824 (#2827)
[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 pub struct LocalUser {
20   pub id: LocalUserId,
21   pub person_id: PersonId,
22   #[serde(skip)]
23   pub password_encrypted: String,
24   pub email: Option<String>,
25   pub show_nsfw: bool,
26   pub theme: 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,
39   #[serde(skip)]
40   pub totp_2fa_secret: Option<String>,
41   pub totp_2fa_url: Option<String>,
42 }
43
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 {
49   #[builder(!default)]
50   pub person_id: PersonId,
51   #[builder(!default)]
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>>,
69 }
70
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>>,
93 }