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