]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/moderator.rs
Split activity table into sent and received parts (fixes #3103) (#3583)
[lemmy.git] / crates / db_schema / src / source / moderator.rs
1 use crate::newtypes::{CommentId, CommunityId, PersonId, PostId};
2 #[cfg(feature = "full")]
3 use crate::schema::{
4   admin_purge_comment,
5   admin_purge_community,
6   admin_purge_person,
7   admin_purge_post,
8   mod_add,
9   mod_add_community,
10   mod_ban,
11   mod_ban_from_community,
12   mod_feature_post,
13   mod_hide_community,
14   mod_lock_post,
15   mod_remove_comment,
16   mod_remove_community,
17   mod_remove_post,
18   mod_transfer_community,
19 };
20 use serde::{Deserialize, Serialize};
21 use serde_with::skip_serializing_none;
22 #[cfg(feature = "full")]
23 use ts_rs::TS;
24
25 #[skip_serializing_none]
26 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
27 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
28 #[cfg_attr(feature = "full", diesel(table_name = mod_remove_post))]
29 #[cfg_attr(feature = "full", ts(export))]
30 /// When a moderator removes a post.
31 pub struct ModRemovePost {
32   pub id: i32,
33   pub mod_person_id: PersonId,
34   pub post_id: PostId,
35   pub reason: Option<String>,
36   pub removed: bool,
37   pub when_: chrono::NaiveDateTime,
38 }
39
40 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
41 #[cfg_attr(feature = "full", diesel(table_name = mod_remove_post))]
42 pub struct ModRemovePostForm {
43   pub mod_person_id: PersonId,
44   pub post_id: PostId,
45   pub reason: Option<String>,
46   pub removed: Option<bool>,
47 }
48
49 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
50 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
51 #[cfg_attr(feature = "full", diesel(table_name = mod_lock_post))]
52 #[cfg_attr(feature = "full", ts(export))]
53 /// When a moderator locks a post (prevents new comments being made).
54 pub struct ModLockPost {
55   pub id: i32,
56   pub mod_person_id: PersonId,
57   pub post_id: PostId,
58   pub locked: bool,
59   pub when_: chrono::NaiveDateTime,
60 }
61
62 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
63 #[cfg_attr(feature = "full", diesel(table_name = mod_lock_post))]
64 pub struct ModLockPostForm {
65   pub mod_person_id: PersonId,
66   pub post_id: PostId,
67   pub locked: Option<bool>,
68 }
69
70 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
71 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
72 #[cfg_attr(feature = "full", diesel(table_name = mod_feature_post))]
73 #[cfg_attr(feature = "full", ts(export))]
74 /// When a moderator features a post on a community (pins it to the top).
75 pub struct ModFeaturePost {
76   pub id: i32,
77   pub mod_person_id: PersonId,
78   pub post_id: PostId,
79   pub featured: bool,
80   pub when_: chrono::NaiveDateTime,
81   pub is_featured_community: bool,
82 }
83
84 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
85 #[cfg_attr(feature = "full", diesel(table_name = mod_feature_post))]
86 pub struct ModFeaturePostForm {
87   pub mod_person_id: PersonId,
88   pub post_id: PostId,
89   pub featured: bool,
90   pub is_featured_community: bool,
91 }
92
93 #[skip_serializing_none]
94 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
95 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
96 #[cfg_attr(feature = "full", diesel(table_name = mod_remove_comment))]
97 #[cfg_attr(feature = "full", ts(export))]
98 /// When a moderator removes a comment.
99 pub struct ModRemoveComment {
100   pub id: i32,
101   pub mod_person_id: PersonId,
102   pub comment_id: CommentId,
103   pub reason: Option<String>,
104   pub removed: bool,
105   pub when_: chrono::NaiveDateTime,
106 }
107
108 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
109 #[cfg_attr(feature = "full", diesel(table_name = mod_remove_comment))]
110 pub struct ModRemoveCommentForm {
111   pub mod_person_id: PersonId,
112   pub comment_id: CommentId,
113   pub reason: Option<String>,
114   pub removed: Option<bool>,
115 }
116
117 #[skip_serializing_none]
118 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
119 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
120 #[cfg_attr(feature = "full", diesel(table_name = mod_remove_community))]
121 #[cfg_attr(feature = "full", ts(export))]
122 /// When a moderator removes a community.
123 pub struct ModRemoveCommunity {
124   pub id: i32,
125   pub mod_person_id: PersonId,
126   pub community_id: CommunityId,
127   pub reason: Option<String>,
128   pub removed: bool,
129   pub expires: Option<chrono::NaiveDateTime>,
130   pub when_: chrono::NaiveDateTime,
131 }
132
133 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
134 #[cfg_attr(feature = "full", diesel(table_name = mod_remove_community))]
135 pub struct ModRemoveCommunityForm {
136   pub mod_person_id: PersonId,
137   pub community_id: CommunityId,
138   pub reason: Option<String>,
139   pub removed: Option<bool>,
140   pub expires: Option<chrono::NaiveDateTime>,
141 }
142
143 #[skip_serializing_none]
144 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
145 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
146 #[cfg_attr(feature = "full", diesel(table_name = mod_ban_from_community))]
147 #[cfg_attr(feature = "full", ts(export))]
148 /// When someone is banned from a community.
149 pub struct ModBanFromCommunity {
150   pub id: i32,
151   pub mod_person_id: PersonId,
152   pub other_person_id: PersonId,
153   pub community_id: CommunityId,
154   pub reason: Option<String>,
155   pub banned: bool,
156   pub expires: Option<chrono::NaiveDateTime>,
157   pub when_: chrono::NaiveDateTime,
158 }
159
160 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
161 #[cfg_attr(feature = "full", diesel(table_name = mod_ban_from_community))]
162 pub struct ModBanFromCommunityForm {
163   pub mod_person_id: PersonId,
164   pub other_person_id: PersonId,
165   pub community_id: CommunityId,
166   pub reason: Option<String>,
167   pub banned: Option<bool>,
168   pub expires: Option<chrono::NaiveDateTime>,
169 }
170
171 #[skip_serializing_none]
172 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
173 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
174 #[cfg_attr(feature = "full", diesel(table_name = mod_ban))]
175 #[cfg_attr(feature = "full", ts(export))]
176 /// When someone is banned from the site.
177 pub struct ModBan {
178   pub id: i32,
179   pub mod_person_id: PersonId,
180   pub other_person_id: PersonId,
181   pub reason: Option<String>,
182   pub banned: bool,
183   pub expires: Option<chrono::NaiveDateTime>,
184   pub when_: chrono::NaiveDateTime,
185 }
186
187 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
188 #[cfg_attr(feature = "full", diesel(table_name = mod_hide_community))]
189 pub struct ModHideCommunityForm {
190   pub community_id: CommunityId,
191   pub mod_person_id: PersonId,
192   pub hidden: Option<bool>,
193   pub reason: Option<String>,
194 }
195
196 #[skip_serializing_none]
197 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
198 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
199 #[cfg_attr(feature = "full", diesel(table_name = mod_hide_community))]
200 #[cfg_attr(feature = "full", ts(export))]
201 /// When a community is hidden from public view.
202 pub struct ModHideCommunity {
203   pub id: i32,
204   pub community_id: CommunityId,
205   pub mod_person_id: PersonId,
206   pub when_: chrono::NaiveDateTime,
207   pub reason: Option<String>,
208   pub hidden: bool,
209 }
210
211 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
212 #[cfg_attr(feature = "full", diesel(table_name = mod_ban))]
213 pub struct ModBanForm {
214   pub mod_person_id: PersonId,
215   pub other_person_id: PersonId,
216   pub reason: Option<String>,
217   pub banned: Option<bool>,
218   pub expires: Option<chrono::NaiveDateTime>,
219 }
220
221 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
222 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
223 #[cfg_attr(feature = "full", diesel(table_name = mod_add_community))]
224 #[cfg_attr(feature = "full", ts(export))]
225 /// When someone is added as a community moderator.
226 pub struct ModAddCommunity {
227   pub id: i32,
228   pub mod_person_id: PersonId,
229   pub other_person_id: PersonId,
230   pub community_id: CommunityId,
231   pub removed: bool,
232   pub when_: chrono::NaiveDateTime,
233 }
234
235 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
236 #[cfg_attr(feature = "full", diesel(table_name = mod_add_community))]
237 pub struct ModAddCommunityForm {
238   pub mod_person_id: PersonId,
239   pub other_person_id: PersonId,
240   pub community_id: CommunityId,
241   pub removed: Option<bool>,
242 }
243
244 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
245 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
246 #[cfg_attr(feature = "full", diesel(table_name = mod_transfer_community))]
247 #[cfg_attr(feature = "full", ts(export))]
248 /// When a moderator transfers a community to a new owner.
249 pub struct ModTransferCommunity {
250   pub id: i32,
251   pub mod_person_id: PersonId,
252   pub other_person_id: PersonId,
253   pub community_id: CommunityId,
254   pub when_: chrono::NaiveDateTime,
255 }
256
257 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
258 #[cfg_attr(feature = "full", diesel(table_name = mod_transfer_community))]
259 pub struct ModTransferCommunityForm {
260   pub mod_person_id: PersonId,
261   pub other_person_id: PersonId,
262   pub community_id: CommunityId,
263 }
264
265 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
266 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
267 #[cfg_attr(feature = "full", diesel(table_name = mod_add))]
268 #[cfg_attr(feature = "full", ts(export))]
269 /// When someone is added as a site moderator.
270 pub struct ModAdd {
271   pub id: i32,
272   pub mod_person_id: PersonId,
273   pub other_person_id: PersonId,
274   pub removed: bool,
275   pub when_: chrono::NaiveDateTime,
276 }
277
278 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
279 #[cfg_attr(feature = "full", diesel(table_name = mod_add))]
280 pub struct ModAddForm {
281   pub mod_person_id: PersonId,
282   pub other_person_id: PersonId,
283   pub removed: Option<bool>,
284 }
285
286 #[skip_serializing_none]
287 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
288 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
289 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_person))]
290 #[cfg_attr(feature = "full", ts(export))]
291 /// When an admin purges a person.
292 pub struct AdminPurgePerson {
293   pub id: i32,
294   pub admin_person_id: PersonId,
295   pub reason: Option<String>,
296   pub when_: chrono::NaiveDateTime,
297 }
298
299 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
300 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_person))]
301 pub struct AdminPurgePersonForm {
302   pub admin_person_id: PersonId,
303   pub reason: Option<String>,
304 }
305
306 #[skip_serializing_none]
307 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
308 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
309 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_community))]
310 #[cfg_attr(feature = "full", ts(export))]
311 /// When an admin purges a community.
312 pub struct AdminPurgeCommunity {
313   pub id: i32,
314   pub admin_person_id: PersonId,
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", diesel(table_name = admin_purge_community))]
321 pub struct AdminPurgeCommunityForm {
322   pub admin_person_id: PersonId,
323   pub reason: Option<String>,
324 }
325
326 #[skip_serializing_none]
327 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
328 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
329 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_post))]
330 #[cfg_attr(feature = "full", ts(export))]
331 /// When an admin purges a post.
332 pub struct AdminPurgePost {
333   pub id: i32,
334   pub admin_person_id: PersonId,
335   pub community_id: CommunityId,
336   pub reason: Option<String>,
337   pub when_: chrono::NaiveDateTime,
338 }
339
340 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
341 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_post))]
342 pub struct AdminPurgePostForm {
343   pub admin_person_id: PersonId,
344   pub community_id: CommunityId,
345   pub reason: Option<String>,
346 }
347
348 #[skip_serializing_none]
349 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
350 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
351 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_comment))]
352 #[cfg_attr(feature = "full", ts(export))]
353 /// When an admin purges a comment.
354 pub struct AdminPurgeComment {
355   pub id: i32,
356   pub admin_person_id: PersonId,
357   pub post_id: PostId,
358   pub reason: Option<String>,
359   pub when_: chrono::NaiveDateTime,
360 }
361
362 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
363 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_comment))]
364 pub struct AdminPurgeCommentForm {
365   pub admin_person_id: PersonId,
366   pub post_id: PostId,
367   pub reason: Option<String>,
368 }