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