]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/person.rs
Adding temporary bans. Fixes #1423 (#1999)
[lemmy.git] / crates / db_schema / src / source / person.rs
1 use crate::{
2   newtypes::{DbUrl, PersonId},
3   schema::{person, person_alias_1, person_alias_2},
4 };
5 use serde::{Deserialize, Serialize};
6
7 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
8 #[table_name = "person"]
9 pub struct Person {
10   pub id: PersonId,
11   pub name: String,
12   pub display_name: Option<String>,
13   pub avatar: Option<DbUrl>,
14   pub banned: bool,
15   pub published: chrono::NaiveDateTime,
16   pub updated: Option<chrono::NaiveDateTime>,
17   pub actor_id: DbUrl,
18   pub bio: Option<String>,
19   pub local: bool,
20   pub private_key: Option<String>,
21   pub public_key: String,
22   pub last_refreshed_at: chrono::NaiveDateTime,
23   pub banner: Option<DbUrl>,
24   pub deleted: bool,
25   pub inbox_url: DbUrl,
26   pub shared_inbox_url: Option<DbUrl>,
27   pub matrix_user_id: Option<String>,
28   pub admin: bool,
29   pub bot_account: bool,
30   pub ban_expires: Option<chrono::NaiveDateTime>,
31 }
32
33 /// A safe representation of person, without the sensitive info
34 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
35 #[table_name = "person"]
36 pub struct PersonSafe {
37   pub id: PersonId,
38   pub name: String,
39   pub display_name: Option<String>,
40   pub avatar: Option<DbUrl>,
41   pub banned: bool,
42   pub published: chrono::NaiveDateTime,
43   pub updated: Option<chrono::NaiveDateTime>,
44   pub actor_id: DbUrl,
45   pub bio: Option<String>,
46   pub local: bool,
47   pub banner: Option<DbUrl>,
48   pub deleted: bool,
49   pub inbox_url: DbUrl,
50   pub shared_inbox_url: Option<DbUrl>,
51   pub matrix_user_id: Option<String>,
52   pub admin: bool,
53   pub bot_account: bool,
54   pub ban_expires: Option<chrono::NaiveDateTime>,
55 }
56
57 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
58 #[table_name = "person_alias_1"]
59 pub struct PersonAlias1 {
60   pub id: PersonId,
61   pub name: String,
62   pub display_name: Option<String>,
63   pub avatar: Option<DbUrl>,
64   pub banned: bool,
65   pub published: chrono::NaiveDateTime,
66   pub updated: Option<chrono::NaiveDateTime>,
67   pub actor_id: DbUrl,
68   pub bio: Option<String>,
69   pub local: bool,
70   pub private_key: Option<String>,
71   pub public_key: String,
72   pub last_refreshed_at: chrono::NaiveDateTime,
73   pub banner: Option<DbUrl>,
74   pub deleted: bool,
75   pub inbox_url: DbUrl,
76   pub shared_inbox_url: Option<DbUrl>,
77   pub matrix_user_id: Option<String>,
78   pub admin: bool,
79   pub bot_account: bool,
80   pub ban_expires: Option<chrono::NaiveDateTime>,
81 }
82
83 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
84 #[table_name = "person_alias_1"]
85 pub struct PersonSafeAlias1 {
86   pub id: PersonId,
87   pub name: String,
88   pub display_name: Option<String>,
89   pub avatar: Option<DbUrl>,
90   pub banned: bool,
91   pub published: chrono::NaiveDateTime,
92   pub updated: Option<chrono::NaiveDateTime>,
93   pub actor_id: DbUrl,
94   pub bio: Option<String>,
95   pub local: bool,
96   pub banner: Option<DbUrl>,
97   pub deleted: bool,
98   pub inbox_url: DbUrl,
99   pub shared_inbox_url: Option<DbUrl>,
100   pub matrix_user_id: Option<String>,
101   pub admin: bool,
102   pub bot_account: bool,
103   pub ban_expires: Option<chrono::NaiveDateTime>,
104 }
105
106 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
107 #[table_name = "person_alias_2"]
108 pub struct PersonAlias2 {
109   pub id: PersonId,
110   pub name: String,
111   pub display_name: Option<String>,
112   pub avatar: Option<DbUrl>,
113   pub banned: bool,
114   pub published: chrono::NaiveDateTime,
115   pub updated: Option<chrono::NaiveDateTime>,
116   pub actor_id: DbUrl,
117   pub bio: Option<String>,
118   pub local: bool,
119   pub private_key: Option<String>,
120   pub public_key: String,
121   pub last_refreshed_at: chrono::NaiveDateTime,
122   pub banner: Option<DbUrl>,
123   pub deleted: bool,
124   pub inbox_url: DbUrl,
125   pub shared_inbox_url: Option<DbUrl>,
126   pub matrix_user_id: Option<String>,
127   pub admin: bool,
128   pub bot_account: bool,
129   pub ban_expires: Option<chrono::NaiveDateTime>,
130 }
131
132 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
133 #[table_name = "person_alias_1"]
134 pub struct PersonSafeAlias2 {
135   pub id: PersonId,
136   pub name: String,
137   pub display_name: Option<String>,
138   pub avatar: Option<DbUrl>,
139   pub banned: bool,
140   pub published: chrono::NaiveDateTime,
141   pub updated: Option<chrono::NaiveDateTime>,
142   pub actor_id: DbUrl,
143   pub bio: Option<String>,
144   pub local: bool,
145   pub banner: Option<DbUrl>,
146   pub deleted: bool,
147   pub inbox_url: DbUrl,
148   pub shared_inbox_url: Option<DbUrl>,
149   pub matrix_user_id: Option<String>,
150   pub admin: bool,
151   pub bot_account: bool,
152   pub ban_expires: Option<chrono::NaiveDateTime>,
153 }
154
155 #[derive(Insertable, AsChangeset, Clone, Default)]
156 #[table_name = "person"]
157 pub struct PersonForm {
158   pub name: String,
159   pub display_name: Option<Option<String>>,
160   pub avatar: Option<Option<DbUrl>>,
161   pub banned: Option<bool>,
162   pub published: Option<chrono::NaiveDateTime>,
163   pub updated: Option<chrono::NaiveDateTime>,
164   pub actor_id: Option<DbUrl>,
165   pub bio: Option<Option<String>>,
166   pub local: Option<bool>,
167   pub private_key: Option<Option<String>>,
168   pub public_key: String,
169   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
170   pub banner: Option<Option<DbUrl>>,
171   pub deleted: Option<bool>,
172   pub inbox_url: Option<DbUrl>,
173   pub shared_inbox_url: Option<Option<DbUrl>>,
174   pub matrix_user_id: Option<Option<String>>,
175   pub admin: Option<bool>,
176   pub bot_account: Option<bool>,
177   pub ban_expires: Option<Option<chrono::NaiveDateTime>>,
178 }