]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/person.rs
Group imports dess (#2526)
[lemmy.git] / crates / db_schema / src / source / person.rs
1 use crate::newtypes::{DbUrl, InstanceId, PersonId};
2 #[cfg(feature = "full")]
3 use crate::schema::person;
4 use serde::{Deserialize, Serialize};
5 use typed_builder::TypedBuilder;
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   pub instance_id: InstanceId,
33 }
34
35 /// A safe representation of person, without the sensitive info
36 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
37 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
38 #[cfg_attr(feature = "full", diesel(table_name = person))]
39 pub struct PersonSafe {
40   pub id: PersonId,
41   pub name: String,
42   pub display_name: Option<String>,
43   pub avatar: Option<DbUrl>,
44   pub banned: bool,
45   pub published: chrono::NaiveDateTime,
46   pub updated: Option<chrono::NaiveDateTime>,
47   pub actor_id: DbUrl,
48   pub bio: Option<String>,
49   pub local: bool,
50   pub banner: Option<DbUrl>,
51   pub deleted: bool,
52   pub inbox_url: DbUrl,
53   pub shared_inbox_url: Option<DbUrl>,
54   pub matrix_user_id: Option<String>,
55   pub admin: bool,
56   pub bot_account: bool,
57   pub ban_expires: Option<chrono::NaiveDateTime>,
58   pub instance_id: InstanceId,
59 }
60
61 #[derive(Clone, TypedBuilder)]
62 #[builder(field_defaults(default))]
63 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
64 #[cfg_attr(feature = "full", diesel(table_name = person))]
65 pub struct PersonInsertForm {
66   #[builder(!default)]
67   pub name: String,
68   #[builder(!default)]
69   pub public_key: String,
70   #[builder(!default)]
71   pub instance_id: InstanceId,
72   pub display_name: Option<String>,
73   pub avatar: Option<DbUrl>,
74   pub banned: Option<bool>,
75   pub published: Option<chrono::NaiveDateTime>,
76   pub updated: Option<chrono::NaiveDateTime>,
77   pub actor_id: Option<DbUrl>,
78   pub bio: Option<String>,
79   pub local: Option<bool>,
80   pub private_key: Option<String>,
81   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
82   pub banner: Option<DbUrl>,
83   pub deleted: Option<bool>,
84   pub inbox_url: Option<DbUrl>,
85   pub shared_inbox_url: Option<DbUrl>,
86   pub matrix_user_id: Option<String>,
87   pub admin: Option<bool>,
88   pub bot_account: Option<bool>,
89   pub ban_expires: Option<chrono::NaiveDateTime>,
90 }
91
92 #[derive(Clone, TypedBuilder)]
93 #[cfg_attr(feature = "full", derive(AsChangeset))]
94 #[cfg_attr(feature = "full", diesel(table_name = person))]
95 #[builder(field_defaults(default))]
96 pub struct PersonUpdateForm {
97   pub display_name: Option<Option<String>>,
98   pub avatar: Option<Option<DbUrl>>,
99   pub banned: Option<bool>,
100   pub updated: Option<Option<chrono::NaiveDateTime>>,
101   pub actor_id: Option<DbUrl>,
102   pub bio: Option<Option<String>>,
103   pub local: Option<bool>,
104   pub public_key: Option<String>,
105   pub private_key: Option<Option<String>>,
106   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
107   pub banner: Option<Option<DbUrl>>,
108   pub deleted: Option<bool>,
109   pub inbox_url: Option<DbUrl>,
110   pub shared_inbox_url: Option<Option<DbUrl>>,
111   pub matrix_user_id: Option<Option<String>>,
112   pub admin: Option<bool>,
113   pub bot_account: Option<bool>,
114   pub ban_expires: Option<Option<chrono::NaiveDateTime>>,
115 }