]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/moderator.rs
7f13eaa9cce8fdcb7fb3fa13d7784a2b63e121ef
[lemmy.git] / crates / db_schema / src / source / moderator.rs
1 use crate::newtypes::{CommentId, CommunityId, PersonId, PostId};
2 use serde::{Deserialize, Serialize};
3
4 #[cfg(feature = "full")]
5 use crate::schema::{
6   admin_purge_comment,
7   admin_purge_community,
8   admin_purge_person,
9   admin_purge_post,
10   mod_add,
11   mod_add_community,
12   mod_ban,
13   mod_ban_from_community,
14   mod_hide_community,
15   mod_lock_post,
16   mod_remove_comment,
17   mod_remove_community,
18   mod_remove_post,
19   mod_sticky_post,
20   mod_transfer_community,
21 };
22
23 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
24 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
25 #[cfg_attr(feature = "full", table_name = "mod_remove_post")]
26 pub struct ModRemovePost {
27   pub id: i32,
28   pub mod_person_id: PersonId,
29   pub post_id: PostId,
30   pub reason: Option<String>,
31   pub removed: Option<bool>,
32   pub when_: chrono::NaiveDateTime,
33 }
34
35 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
36 #[cfg_attr(feature = "full", table_name = "mod_remove_post")]
37 pub struct ModRemovePostForm {
38   pub mod_person_id: PersonId,
39   pub post_id: PostId,
40   pub reason: Option<String>,
41   pub removed: Option<bool>,
42 }
43
44 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
45 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
46 #[cfg_attr(feature = "full", table_name = "mod_lock_post")]
47 pub struct ModLockPost {
48   pub id: i32,
49   pub mod_person_id: PersonId,
50   pub post_id: PostId,
51   pub locked: Option<bool>,
52   pub when_: chrono::NaiveDateTime,
53 }
54
55 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
56 #[cfg_attr(feature = "full", table_name = "mod_lock_post")]
57 pub struct ModLockPostForm {
58   pub mod_person_id: PersonId,
59   pub post_id: PostId,
60   pub locked: Option<bool>,
61 }
62
63 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
64 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
65 #[cfg_attr(feature = "full", table_name = "mod_sticky_post")]
66 pub struct ModStickyPost {
67   pub id: i32,
68   pub mod_person_id: PersonId,
69   pub post_id: PostId,
70   pub stickied: Option<bool>,
71   pub when_: chrono::NaiveDateTime,
72 }
73
74 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
75 #[cfg_attr(feature = "full", table_name = "mod_sticky_post")]
76 pub struct ModStickyPostForm {
77   pub mod_person_id: PersonId,
78   pub post_id: PostId,
79   pub stickied: Option<bool>,
80 }
81
82 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
83 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
84 #[cfg_attr(feature = "full", table_name = "mod_remove_comment")]
85 pub struct ModRemoveComment {
86   pub id: i32,
87   pub mod_person_id: PersonId,
88   pub comment_id: CommentId,
89   pub reason: Option<String>,
90   pub removed: Option<bool>,
91   pub when_: chrono::NaiveDateTime,
92 }
93
94 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
95 #[cfg_attr(feature = "full", table_name = "mod_remove_comment")]
96 pub struct ModRemoveCommentForm {
97   pub mod_person_id: PersonId,
98   pub comment_id: CommentId,
99   pub reason: Option<String>,
100   pub removed: Option<bool>,
101 }
102
103 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
104 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
105 #[cfg_attr(feature = "full", table_name = "mod_remove_community")]
106 pub struct ModRemoveCommunity {
107   pub id: i32,
108   pub mod_person_id: PersonId,
109   pub community_id: CommunityId,
110   pub reason: Option<String>,
111   pub removed: Option<bool>,
112   pub expires: Option<chrono::NaiveDateTime>,
113   pub when_: chrono::NaiveDateTime,
114 }
115
116 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
117 #[cfg_attr(feature = "full", table_name = "mod_remove_community")]
118 pub struct ModRemoveCommunityForm {
119   pub mod_person_id: PersonId,
120   pub community_id: CommunityId,
121   pub reason: Option<String>,
122   pub removed: Option<bool>,
123   pub expires: Option<chrono::NaiveDateTime>,
124 }
125
126 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
127 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
128 #[cfg_attr(feature = "full", table_name = "mod_ban_from_community")]
129 pub struct ModBanFromCommunity {
130   pub id: i32,
131   pub mod_person_id: PersonId,
132   pub other_person_id: PersonId,
133   pub community_id: CommunityId,
134   pub reason: Option<String>,
135   pub banned: Option<bool>,
136   pub expires: Option<chrono::NaiveDateTime>,
137   pub when_: chrono::NaiveDateTime,
138 }
139
140 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
141 #[cfg_attr(feature = "full", table_name = "mod_ban_from_community")]
142 pub struct ModBanFromCommunityForm {
143   pub mod_person_id: PersonId,
144   pub other_person_id: PersonId,
145   pub community_id: CommunityId,
146   pub reason: Option<String>,
147   pub banned: Option<bool>,
148   pub expires: Option<chrono::NaiveDateTime>,
149 }
150
151 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
152 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
153 #[cfg_attr(feature = "full", table_name = "mod_ban")]
154 pub struct ModBan {
155   pub id: i32,
156   pub mod_person_id: PersonId,
157   pub other_person_id: PersonId,
158   pub reason: Option<String>,
159   pub banned: Option<bool>,
160   pub expires: Option<chrono::NaiveDateTime>,
161   pub when_: chrono::NaiveDateTime,
162 }
163
164 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
165 #[cfg_attr(feature = "full", table_name = "mod_hide_community")]
166 pub struct ModHideCommunityForm {
167   pub community_id: CommunityId,
168   pub mod_person_id: PersonId,
169   pub hidden: Option<bool>,
170   pub reason: Option<String>,
171 }
172 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
173 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
174 #[cfg_attr(feature = "full", table_name = "mod_hide_community")]
175 pub struct ModHideCommunity {
176   pub id: i32,
177   pub community_id: CommunityId,
178   pub mod_person_id: PersonId,
179   pub reason: Option<String>,
180   pub hidden: Option<bool>,
181   pub when_: chrono::NaiveDateTime,
182 }
183
184 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
185 #[cfg_attr(feature = "full", table_name = "mod_ban")]
186 pub struct ModBanForm {
187   pub mod_person_id: PersonId,
188   pub other_person_id: PersonId,
189   pub reason: Option<String>,
190   pub banned: Option<bool>,
191   pub expires: Option<chrono::NaiveDateTime>,
192 }
193
194 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
195 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
196 #[cfg_attr(feature = "full", table_name = "mod_add_community")]
197 pub struct ModAddCommunity {
198   pub id: i32,
199   pub mod_person_id: PersonId,
200   pub other_person_id: PersonId,
201   pub community_id: CommunityId,
202   pub removed: Option<bool>,
203   pub when_: chrono::NaiveDateTime,
204 }
205
206 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
207 #[cfg_attr(feature = "full", table_name = "mod_add_community")]
208 pub struct ModAddCommunityForm {
209   pub mod_person_id: PersonId,
210   pub other_person_id: PersonId,
211   pub community_id: CommunityId,
212   pub removed: Option<bool>,
213 }
214
215 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
216 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
217 #[cfg_attr(feature = "full", table_name = "mod_transfer_community")]
218 pub struct ModTransferCommunity {
219   pub id: i32,
220   pub mod_person_id: PersonId,
221   pub other_person_id: PersonId,
222   pub community_id: CommunityId,
223   pub removed: Option<bool>,
224   pub when_: chrono::NaiveDateTime,
225 }
226
227 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
228 #[cfg_attr(feature = "full", table_name = "mod_transfer_community")]
229 pub struct ModTransferCommunityForm {
230   pub mod_person_id: PersonId,
231   pub other_person_id: PersonId,
232   pub community_id: CommunityId,
233   pub removed: Option<bool>,
234 }
235
236 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
237 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
238 #[cfg_attr(feature = "full", table_name = "mod_add")]
239 pub struct ModAdd {
240   pub id: i32,
241   pub mod_person_id: PersonId,
242   pub other_person_id: PersonId,
243   pub removed: Option<bool>,
244   pub when_: chrono::NaiveDateTime,
245 }
246
247 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
248 #[cfg_attr(feature = "full", table_name = "mod_add")]
249 pub struct ModAddForm {
250   pub mod_person_id: PersonId,
251   pub other_person_id: PersonId,
252   pub removed: Option<bool>,
253 }
254
255 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
256 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
257 #[cfg_attr(feature = "full", table_name = "admin_purge_person")]
258 pub struct AdminPurgePerson {
259   pub id: i32,
260   pub admin_person_id: PersonId,
261   pub reason: Option<String>,
262   pub when_: chrono::NaiveDateTime,
263 }
264
265 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
266 #[cfg_attr(feature = "full", table_name = "admin_purge_person")]
267 pub struct AdminPurgePersonForm {
268   pub admin_person_id: PersonId,
269   pub reason: Option<String>,
270 }
271
272 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
273 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
274 #[cfg_attr(feature = "full", table_name = "admin_purge_community")]
275 pub struct AdminPurgeCommunity {
276   pub id: i32,
277   pub admin_person_id: PersonId,
278   pub reason: Option<String>,
279   pub when_: chrono::NaiveDateTime,
280 }
281
282 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
283 #[cfg_attr(feature = "full", table_name = "admin_purge_community")]
284 pub struct AdminPurgeCommunityForm {
285   pub admin_person_id: PersonId,
286   pub reason: Option<String>,
287 }
288
289 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
290 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
291 #[cfg_attr(feature = "full", table_name = "admin_purge_post")]
292 pub struct AdminPurgePost {
293   pub id: i32,
294   pub admin_person_id: PersonId,
295   pub community_id: CommunityId,
296   pub reason: Option<String>,
297   pub when_: chrono::NaiveDateTime,
298 }
299
300 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
301 #[cfg_attr(feature = "full", table_name = "admin_purge_post")]
302 pub struct AdminPurgePostForm {
303   pub admin_person_id: PersonId,
304   pub community_id: CommunityId,
305   pub reason: Option<String>,
306 }
307
308 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
309 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
310 #[cfg_attr(feature = "full", table_name = "admin_purge_comment")]
311 pub struct AdminPurgeComment {
312   pub id: i32,
313   pub admin_person_id: PersonId,
314   pub post_id: PostId,
315   pub reason: Option<String>,
316   pub when_: chrono::NaiveDateTime,
317 }
318
319 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
320 #[cfg_attr(feature = "full", table_name = "admin_purge_comment")]
321 pub struct AdminPurgeCommentForm {
322   pub admin_person_id: PersonId,
323   pub post_id: PostId,
324   pub reason: Option<String>,
325 }