]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/person.rs
5d9d603de85d1d64b31bcaf70511304cb6744f8a
[lemmy.git] / crates / db_schema / src / source / person.rs
1 use crate::newtypes::{DbUrl, PersonId};
2 use serde::{Deserialize, Serialize};
3
4 #[cfg(feature = "full")]
5 use crate::schema::person;
6
7 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", diesel(table_name = person))]
10 pub struct Person {
11   pub id: PersonId,
12   pub name: String,
13   pub display_name: Option<String>,
14   pub avatar: Option<DbUrl>,
15   pub banned: bool,
16   pub published: chrono::NaiveDateTime,
17   pub updated: Option<chrono::NaiveDateTime>,
18   pub actor_id: DbUrl,
19   pub bio: Option<String>,
20   pub local: bool,
21   pub private_key: Option<String>,
22   pub public_key: String,
23   pub last_refreshed_at: chrono::NaiveDateTime,
24   pub banner: Option<DbUrl>,
25   pub deleted: bool,
26   pub inbox_url: DbUrl,
27   pub shared_inbox_url: Option<DbUrl>,
28   pub matrix_user_id: Option<String>,
29   pub admin: bool,
30   pub bot_account: bool,
31   pub ban_expires: Option<chrono::NaiveDateTime>,
32 }
33
34 /// A safe representation of person, without the sensitive info
35 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
36 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
37 #[cfg_attr(feature = "full", diesel(table_name = person))]
38 pub struct PersonSafe {
39   pub id: PersonId,
40   pub name: String,
41   pub display_name: Option<String>,
42   pub avatar: Option<DbUrl>,
43   pub banned: bool,
44   pub published: chrono::NaiveDateTime,
45   pub updated: Option<chrono::NaiveDateTime>,
46   pub actor_id: DbUrl,
47   pub bio: Option<String>,
48   pub local: bool,
49   pub banner: Option<DbUrl>,
50   pub deleted: bool,
51   pub inbox_url: DbUrl,
52   pub shared_inbox_url: Option<DbUrl>,
53   pub matrix_user_id: Option<String>,
54   pub admin: bool,
55   pub bot_account: bool,
56   pub ban_expires: Option<chrono::NaiveDateTime>,
57 }
58
59 #[derive(Clone, Default)]
60 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
61 #[cfg_attr(feature = "full", diesel(table_name = person))]
62 pub struct PersonForm {
63   pub name: String,
64   pub display_name: Option<Option<String>>,
65   pub avatar: Option<Option<DbUrl>>,
66   pub banned: Option<bool>,
67   pub published: Option<chrono::NaiveDateTime>,
68   pub updated: Option<chrono::NaiveDateTime>,
69   pub actor_id: Option<DbUrl>,
70   pub bio: Option<Option<String>>,
71   pub local: Option<bool>,
72   pub private_key: Option<Option<String>>,
73   pub public_key: Option<String>,
74   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
75   pub banner: Option<Option<DbUrl>>,
76   pub deleted: Option<bool>,
77   pub inbox_url: Option<DbUrl>,
78   pub shared_inbox_url: Option<Option<DbUrl>>,
79   pub matrix_user_id: Option<Option<String>>,
80   pub admin: Option<bool>,
81   pub bot_account: Option<bool>,
82   pub ban_expires: Option<Option<chrono::NaiveDateTime>>,
83 }