]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/local_user.rs
First pass at invite-only migration. (#1949)
[lemmy.git] / crates / db_schema / src / source / local_user.rs
1 use crate::{
2   newtypes::{LocalUserId, PersonId},
3   schema::local_user,
4 };
5 use serde::{Deserialize, Serialize};
6
7 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
8 #[table_name = "local_user"]
9 pub struct LocalUser {
10   pub id: LocalUserId,
11   pub person_id: PersonId,
12   pub password_encrypted: String,
13   pub email: Option<String>,
14   pub show_nsfw: bool,
15   pub theme: String,
16   pub default_sort_type: i16,
17   pub default_listing_type: i16,
18   pub lang: String,
19   pub show_avatars: bool,
20   pub send_notifications_to_email: bool,
21   pub validator_time: chrono::NaiveDateTime,
22   pub show_bot_accounts: bool,
23   pub show_scores: bool,
24   pub show_read_posts: bool,
25   pub show_new_post_notifs: bool,
26   pub email_verified: bool,
27   pub accepted_application: bool,
28 }
29
30 // TODO redo these, check table defaults
31 #[derive(Insertable, AsChangeset, Clone, Default)]
32 #[table_name = "local_user"]
33 pub struct LocalUserForm {
34   pub person_id: Option<PersonId>,
35   pub password_encrypted: Option<String>,
36   pub email: Option<Option<String>>,
37   pub show_nsfw: Option<bool>,
38   pub theme: Option<String>,
39   pub default_sort_type: Option<i16>,
40   pub default_listing_type: Option<i16>,
41   pub lang: Option<String>,
42   pub show_avatars: Option<bool>,
43   pub send_notifications_to_email: Option<bool>,
44   pub show_bot_accounts: Option<bool>,
45   pub show_scores: Option<bool>,
46   pub show_read_posts: Option<bool>,
47   pub show_new_post_notifs: Option<bool>,
48   pub email_verified: Option<bool>,
49   pub accepted_application: Option<bool>,
50 }
51
52 /// A local user view that removes password encrypted
53 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
54 #[table_name = "local_user"]
55 pub struct LocalUserSettings {
56   pub id: LocalUserId,
57   pub person_id: PersonId,
58   pub email: Option<String>,
59   pub show_nsfw: bool,
60   pub theme: String,
61   pub default_sort_type: i16,
62   pub default_listing_type: i16,
63   pub lang: String,
64   pub show_avatars: bool,
65   pub send_notifications_to_email: bool,
66   pub validator_time: chrono::NaiveDateTime,
67   pub show_bot_accounts: bool,
68   pub show_scores: bool,
69   pub show_read_posts: bool,
70   pub show_new_post_notifs: bool,
71   pub email_verified: bool,
72   pub accepted_application: bool,
73 }