]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/moderator.rs
Add support for Featured Posts (#2585)
[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: Option<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: Option<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: Option<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: Option<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: Option<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: Option<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 reason: Option<String>,
181   pub hidden: Option<bool>,
182   pub when_: chrono::NaiveDateTime,
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: Option<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 removed: Option<bool>,
225   pub when_: chrono::NaiveDateTime,
226 }
227
228 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
229 #[cfg_attr(feature = "full", diesel(table_name = mod_transfer_community))]
230 pub struct ModTransferCommunityForm {
231   pub mod_person_id: PersonId,
232   pub other_person_id: PersonId,
233   pub community_id: CommunityId,
234   pub removed: Option<bool>,
235 }
236
237 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
238 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
239 #[cfg_attr(feature = "full", diesel(table_name = mod_add))]
240 pub struct ModAdd {
241   pub id: i32,
242   pub mod_person_id: PersonId,
243   pub other_person_id: PersonId,
244   pub removed: Option<bool>,
245   pub when_: chrono::NaiveDateTime,
246 }
247
248 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
249 #[cfg_attr(feature = "full", diesel(table_name = mod_add))]
250 pub struct ModAddForm {
251   pub mod_person_id: PersonId,
252   pub other_person_id: PersonId,
253   pub removed: Option<bool>,
254 }
255
256 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
257 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
258 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_person))]
259 pub struct AdminPurgePerson {
260   pub id: i32,
261   pub admin_person_id: PersonId,
262   pub reason: Option<String>,
263   pub when_: chrono::NaiveDateTime,
264 }
265
266 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
267 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_person))]
268 pub struct AdminPurgePersonForm {
269   pub admin_person_id: PersonId,
270   pub reason: Option<String>,
271 }
272
273 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
274 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
275 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_community))]
276 pub struct AdminPurgeCommunity {
277   pub id: i32,
278   pub admin_person_id: PersonId,
279   pub reason: Option<String>,
280   pub when_: chrono::NaiveDateTime,
281 }
282
283 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
284 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_community))]
285 pub struct AdminPurgeCommunityForm {
286   pub admin_person_id: PersonId,
287   pub reason: Option<String>,
288 }
289
290 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
291 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
292 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_post))]
293 pub struct AdminPurgePost {
294   pub id: i32,
295   pub admin_person_id: PersonId,
296   pub community_id: CommunityId,
297   pub reason: Option<String>,
298   pub when_: chrono::NaiveDateTime,
299 }
300
301 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
302 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_post))]
303 pub struct AdminPurgePostForm {
304   pub admin_person_id: PersonId,
305   pub community_id: CommunityId,
306   pub reason: Option<String>,
307 }
308
309 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
310 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
311 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_comment))]
312 pub struct AdminPurgeComment {
313   pub id: i32,
314   pub admin_person_id: PersonId,
315   pub post_id: PostId,
316   pub reason: Option<String>,
317   pub when_: chrono::NaiveDateTime,
318 }
319
320 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
321 #[cfg_attr(feature = "full", diesel(table_name = admin_purge_comment))]
322 pub struct AdminPurgeCommentForm {
323   pub admin_person_id: PersonId,
324   pub post_id: PostId,
325   pub reason: Option<String>,
326 }