]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/local_user.rs
Merge branch 'release/v0.10'
[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_scores: bool,
20 }
21
22 // TODO redo these, check table defaults
23 #[derive(Insertable, AsChangeset, Clone, Default)]
24 #[table_name = "local_user"]
25 pub struct LocalUserForm {
26   pub person_id: PersonId,
27   pub password_encrypted: String,
28   pub email: Option<Option<String>>,
29   pub show_nsfw: Option<bool>,
30   pub theme: Option<String>,
31   pub default_sort_type: Option<i16>,
32   pub default_listing_type: Option<i16>,
33   pub lang: Option<String>,
34   pub show_avatars: Option<bool>,
35   pub send_notifications_to_email: Option<bool>,
36   pub show_scores: Option<bool>,
37 }
38
39 /// A local user view that removes password encrypted
40 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
41 #[table_name = "local_user"]
42 pub struct LocalUserSettings {
43   pub id: LocalUserId,
44   pub person_id: PersonId,
45   pub email: Option<String>,
46   pub show_nsfw: bool,
47   pub theme: String,
48   pub default_sort_type: i16,
49   pub default_listing_type: i16,
50   pub lang: String,
51   pub show_avatars: bool,
52   pub send_notifications_to_email: bool,
53   pub validator_time: chrono::NaiveDateTime,
54   pub show_scores: bool,
55 }