]> Untitled Git - lemmy.git/blob - server/src/db/moderator.rs
Adding emoji support.
[lemmy.git] / server / src / db / moderator.rs
1 use crate::schema::{mod_remove_post, mod_lock_post, mod_remove_comment, mod_remove_community, mod_ban_from_community, mod_ban, mod_add_community, mod_add};
2 use super::*;
3
4 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
5 #[table_name="mod_remove_post"]
6 pub struct ModRemovePost {
7   pub id: i32,
8   pub mod_user_id: i32,
9   pub post_id: i32,
10   pub reason: Option<String>,
11   pub removed: Option<bool>,
12   pub when_: chrono::NaiveDateTime,
13 }
14
15 #[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
16 #[table_name="mod_remove_post"]
17 pub struct ModRemovePostForm {
18   pub mod_user_id: i32,
19   pub post_id: i32,
20   pub reason: Option<String>,
21   pub removed: Option<bool>,
22 }
23
24 impl Crud<ModRemovePostForm> for ModRemovePost {
25   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
26     use crate::schema::mod_remove_post::dsl::*;
27     mod_remove_post.find(from_id)
28       .first::<Self>(conn)
29   }
30
31   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
32     use crate::schema::mod_remove_post::dsl::*;
33     diesel::delete(mod_remove_post.find(from_id))
34       .execute(conn)
35   }
36
37   fn create(conn: &PgConnection, form: &ModRemovePostForm) -> Result<Self, Error> {
38     use crate::schema::mod_remove_post::dsl::*;
39       insert_into(mod_remove_post)
40         .values(form)
41         .get_result::<Self>(conn)
42   }
43
44   fn update(conn: &PgConnection, from_id: i32, form: &ModRemovePostForm) -> Result<Self, Error> {
45     use crate::schema::mod_remove_post::dsl::*;
46     diesel::update(mod_remove_post.find(from_id))
47       .set(form)
48       .get_result::<Self>(conn)
49   }
50 }
51
52
53
54 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
55 #[table_name="mod_lock_post"]
56 pub struct ModLockPost {
57   pub id: i32,
58   pub mod_user_id: i32,
59   pub post_id: i32,
60   pub locked: Option<bool>,
61   pub when_: chrono::NaiveDateTime,
62 }
63
64 #[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
65 #[table_name="mod_lock_post"]
66 pub struct ModLockPostForm {
67   pub mod_user_id: i32,
68   pub post_id: i32,
69   pub locked: Option<bool>,
70 }
71
72 impl Crud<ModLockPostForm> for ModLockPost {
73   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
74     use crate::schema::mod_lock_post::dsl::*;
75     mod_lock_post.find(from_id)
76       .first::<Self>(conn)
77   }
78
79   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
80     use crate::schema::mod_lock_post::dsl::*;
81     diesel::delete(mod_lock_post.find(from_id))
82       .execute(conn)
83   }
84
85   fn create(conn: &PgConnection, form: &ModLockPostForm) -> Result<Self, Error> {
86     use crate::schema::mod_lock_post::dsl::*;
87       insert_into(mod_lock_post)
88         .values(form)
89         .get_result::<Self>(conn)
90   }
91
92   fn update(conn: &PgConnection, from_id: i32, form: &ModLockPostForm) -> Result<Self, Error> {
93     use crate::schema::mod_lock_post::dsl::*;
94     diesel::update(mod_lock_post.find(from_id))
95       .set(form)
96       .get_result::<Self>(conn)
97   }
98 }
99
100 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
101 #[table_name="mod_remove_comment"]
102 pub struct ModRemoveComment {
103   pub id: i32,
104   pub mod_user_id: i32,
105   pub comment_id: i32,
106   pub reason: Option<String>,
107   pub removed: Option<bool>,
108   pub when_: chrono::NaiveDateTime,
109 }
110
111 #[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
112 #[table_name="mod_remove_comment"]
113 pub struct ModRemoveCommentForm {
114   pub mod_user_id: i32,
115   pub comment_id: i32,
116   pub reason: Option<String>,
117   pub removed: Option<bool>,
118 }
119
120 impl Crud<ModRemoveCommentForm> for ModRemoveComment {
121   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
122     use crate::schema::mod_remove_comment::dsl::*;
123     mod_remove_comment.find(from_id)
124       .first::<Self>(conn)
125   }
126
127   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
128     use crate::schema::mod_remove_comment::dsl::*;
129     diesel::delete(mod_remove_comment.find(from_id))
130       .execute(conn)
131   }
132
133   fn create(conn: &PgConnection, form: &ModRemoveCommentForm) -> Result<Self, Error> {
134     use crate::schema::mod_remove_comment::dsl::*;
135       insert_into(mod_remove_comment)
136         .values(form)
137         .get_result::<Self>(conn)
138   }
139
140   fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommentForm) -> Result<Self, Error> {
141     use crate::schema::mod_remove_comment::dsl::*;
142     diesel::update(mod_remove_comment.find(from_id))
143       .set(form)
144       .get_result::<Self>(conn)
145   }
146 }
147
148 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
149 #[table_name="mod_remove_community"]
150 pub struct ModRemoveCommunity {
151   pub id: i32,
152   pub mod_user_id: i32,
153   pub community_id: i32,
154   pub reason: Option<String>,
155   pub removed: Option<bool>,
156   pub expires: Option<chrono::NaiveDateTime>,
157   pub when_: chrono::NaiveDateTime,
158 }
159
160 #[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
161 #[table_name="mod_remove_community"]
162 pub struct ModRemoveCommunityForm {
163   pub mod_user_id: i32,
164   pub community_id: i32,
165   pub reason: Option<String>,
166   pub removed: Option<bool>,
167   pub expires: Option<chrono::NaiveDateTime>,
168 }
169
170 impl Crud<ModRemoveCommunityForm> for ModRemoveCommunity {
171   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
172     use crate::schema::mod_remove_community::dsl::*;
173     mod_remove_community.find(from_id)
174       .first::<Self>(conn)
175   }
176
177   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
178     use crate::schema::mod_remove_community::dsl::*;
179     diesel::delete(mod_remove_community.find(from_id))
180       .execute(conn)
181   }
182
183   fn create(conn: &PgConnection, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
184     use crate::schema::mod_remove_community::dsl::*;
185       insert_into(mod_remove_community)
186         .values(form)
187         .get_result::<Self>(conn)
188   }
189
190   fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
191     use crate::schema::mod_remove_community::dsl::*;
192     diesel::update(mod_remove_community.find(from_id))
193       .set(form)
194       .get_result::<Self>(conn)
195   }
196 }
197
198 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
199 #[table_name="mod_ban_from_community"]
200 pub struct ModBanFromCommunity {
201   pub id: i32,
202   pub mod_user_id: i32,
203   pub other_user_id: i32,
204   pub community_id: i32,
205   pub reason: Option<String>,
206   pub banned: Option<bool>,
207   pub expires: Option<chrono::NaiveDateTime>,
208   pub when_: chrono::NaiveDateTime,
209 }
210
211 #[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
212 #[table_name="mod_ban_from_community"]
213 pub struct ModBanFromCommunityForm {
214   pub mod_user_id: i32,
215   pub other_user_id: i32,
216   pub community_id: i32,
217   pub reason: Option<String>,
218   pub banned: Option<bool>,
219   pub expires: Option<chrono::NaiveDateTime>,
220 }
221
222 impl Crud<ModBanFromCommunityForm> for ModBanFromCommunity {
223   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
224     use crate::schema::mod_ban_from_community::dsl::*;
225     mod_ban_from_community.find(from_id)
226       .first::<Self>(conn)
227   }
228
229   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
230     use crate::schema::mod_ban_from_community::dsl::*;
231     diesel::delete(mod_ban_from_community.find(from_id))
232       .execute(conn)
233   }
234
235   fn create(conn: &PgConnection, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
236     use crate::schema::mod_ban_from_community::dsl::*;
237       insert_into(mod_ban_from_community)
238         .values(form)
239         .get_result::<Self>(conn)
240   }
241
242   fn update(conn: &PgConnection, from_id: i32, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
243     use crate::schema::mod_ban_from_community::dsl::*;
244     diesel::update(mod_ban_from_community.find(from_id))
245       .set(form)
246       .get_result::<Self>(conn)
247   }
248 }
249
250
251 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
252 #[table_name="mod_ban"]
253 pub struct ModBan {
254   pub id: i32,
255   pub mod_user_id: i32,
256   pub other_user_id: i32,
257   pub reason: Option<String>,
258   pub banned: Option<bool>,
259   pub expires: Option<chrono::NaiveDateTime>,
260   pub when_: chrono::NaiveDateTime,
261 }
262
263 #[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
264 #[table_name="mod_ban"]
265 pub struct ModBanForm {
266   pub mod_user_id: i32,
267   pub other_user_id: i32,
268   pub reason: Option<String>,
269   pub banned: Option<bool>,
270   pub expires: Option<chrono::NaiveDateTime>,
271 }
272
273 impl Crud<ModBanForm> for ModBan {
274   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
275     use crate::schema::mod_ban::dsl::*;
276     mod_ban.find(from_id)
277       .first::<Self>(conn)
278   }
279
280   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
281     use crate::schema::mod_ban::dsl::*;
282     diesel::delete(mod_ban.find(from_id))
283       .execute(conn)
284   }
285
286   fn create(conn: &PgConnection, form: &ModBanForm) -> Result<Self, Error> {
287     use crate::schema::mod_ban::dsl::*;
288       insert_into(mod_ban)
289         .values(form)
290         .get_result::<Self>(conn)
291   }
292
293   fn update(conn: &PgConnection, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
294     use crate::schema::mod_ban::dsl::*;
295     diesel::update(mod_ban.find(from_id))
296       .set(form)
297       .get_result::<Self>(conn)
298   }
299 }
300
301 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
302 #[table_name="mod_add_community"]
303 pub struct ModAddCommunity {
304   pub id: i32,
305   pub mod_user_id: i32,
306   pub other_user_id: i32,
307   pub community_id: i32,
308   pub removed: Option<bool>,
309   pub when_: chrono::NaiveDateTime,
310 }
311
312 #[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
313 #[table_name="mod_add_community"]
314 pub struct ModAddCommunityForm {
315   pub mod_user_id: i32,
316   pub other_user_id: i32,
317   pub community_id: i32,
318   pub removed: Option<bool>,
319 }
320
321 impl Crud<ModAddCommunityForm> for ModAddCommunity {
322   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
323     use crate::schema::mod_add_community::dsl::*;
324     mod_add_community.find(from_id)
325       .first::<Self>(conn)
326   }
327
328   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
329     use crate::schema::mod_add_community::dsl::*;
330     diesel::delete(mod_add_community.find(from_id))
331       .execute(conn)
332   }
333
334   fn create(conn: &PgConnection, form: &ModAddCommunityForm) -> Result<Self, Error> {
335     use crate::schema::mod_add_community::dsl::*;
336       insert_into(mod_add_community)
337         .values(form)
338         .get_result::<Self>(conn)
339   }
340
341   fn update(conn: &PgConnection, from_id: i32, form: &ModAddCommunityForm) -> Result<Self, Error> {
342     use crate::schema::mod_add_community::dsl::*;
343     diesel::update(mod_add_community.find(from_id))
344       .set(form)
345       .get_result::<Self>(conn)
346   }
347 }
348
349 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
350 #[table_name="mod_add"]
351 pub struct ModAdd {
352   pub id: i32,
353   pub mod_user_id: i32,
354   pub other_user_id: i32,
355   pub removed: Option<bool>,
356   pub when_: chrono::NaiveDateTime,
357 }
358
359 #[derive(Insertable, AsChangeset, Clone, Serialize, Deserialize)]
360 #[table_name="mod_add"]
361 pub struct ModAddForm {
362   pub mod_user_id: i32,
363   pub other_user_id: i32,
364   pub removed: Option<bool>,
365 }
366
367 impl Crud<ModAddForm> for ModAdd {
368   fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
369     use crate::schema::mod_add::dsl::*;
370     mod_add.find(from_id)
371       .first::<Self>(conn)
372   }
373
374   fn delete(conn: &PgConnection, from_id: i32) -> Result<usize, Error> {
375     use crate::schema::mod_add::dsl::*;
376     diesel::delete(mod_add.find(from_id))
377       .execute(conn)
378   }
379
380   fn create(conn: &PgConnection, form: &ModAddForm) -> Result<Self, Error> {
381     use crate::schema::mod_add::dsl::*;
382       insert_into(mod_add)
383         .values(form)
384         .get_result::<Self>(conn)
385   }
386
387   fn update(conn: &PgConnection, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
388     use crate::schema::mod_add::dsl::*;
389     diesel::update(mod_add.find(from_id))
390       .set(form)
391       .get_result::<Self>(conn)
392   }
393 }
394
395 #[cfg(test)]
396 mod tests {
397   use super::*;
398   use super::super::user::*;
399   use super::super::post::*;
400   use super::super::community::*;
401   use super::super::comment::*;
402   // use Crud;
403  #[test]
404   fn test_crud() {
405     let conn = establish_connection();
406
407     let new_mod = UserForm {
408       name: "the mod".into(),
409       fedi_name: "rrf".into(),
410       preferred_username: None,
411       password_encrypted: "nope".into(),
412       email: None,
413       admin: false,
414       banned: false,
415       updated: None,
416       show_nsfw: false,
417     };
418
419     let inserted_mod = User_::create(&conn, &new_mod).unwrap();
420
421     let new_user = UserForm {
422       name: "jim2".into(),
423       fedi_name: "rrf".into(),
424       preferred_username: None,
425       password_encrypted: "nope".into(),
426       email: None,
427       admin: false,
428       banned: false,
429       updated: None,
430       show_nsfw: false,
431     };
432
433     let inserted_user = User_::create(&conn, &new_user).unwrap();
434
435     let new_community = CommunityForm {
436       name: "mod_community".to_string(),
437       title: "nada".to_owned(),
438       description: None,
439       category_id: 1,
440       creator_id: inserted_user.id,
441       removed: None,
442       deleted: None,
443       updated: None,
444       nsfw: false,
445     };
446
447     let inserted_community = Community::create(&conn, &new_community).unwrap();
448     
449     let new_post = PostForm {
450       name: "A test post thweep".into(),
451       url: None,
452       body: None,
453       creator_id: inserted_user.id,
454       community_id: inserted_community.id,
455       removed: None,
456       deleted: None,
457       locked: None,
458       updated: None,
459       nsfw: false,
460     };
461
462     let inserted_post = Post::create(&conn, &new_post).unwrap();
463
464     let comment_form = CommentForm {
465       content: "A test comment".into(),
466       creator_id: inserted_user.id,
467       post_id: inserted_post.id,
468       removed: None,
469       deleted: None,
470       read: None,
471       parent_id: None,
472       updated: None
473     };
474
475     let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
476
477     // Now the actual tests
478
479     // remove post
480     let mod_remove_post_form = ModRemovePostForm {
481       mod_user_id: inserted_mod.id,
482       post_id: inserted_post.id,
483       reason: None,
484       removed: None,
485     };
486     let inserted_mod_remove_post = ModRemovePost::create(&conn, &mod_remove_post_form).unwrap();
487     let read_moderator_remove_post = ModRemovePost::read(&conn, inserted_mod_remove_post.id).unwrap();
488     let expected_moderator_remove_post = ModRemovePost {
489       id: inserted_mod_remove_post.id,
490       post_id: inserted_post.id,
491       mod_user_id: inserted_mod.id,
492       reason: None,
493       removed: Some(true),
494       when_: inserted_mod_remove_post.when_,
495     };
496
497     // lock post
498
499     let mod_lock_post_form = ModLockPostForm {
500       mod_user_id: inserted_mod.id,
501       post_id: inserted_post.id,
502       locked: None,
503     };
504     let inserted_mod_lock_post = ModLockPost::create(&conn, &mod_lock_post_form).unwrap();
505     let read_moderator_lock_post = ModLockPost::read(&conn, inserted_mod_lock_post.id).unwrap();
506     let expected_moderator_lock_post = ModLockPost {
507       id: inserted_mod_lock_post.id,
508       post_id: inserted_post.id,
509       mod_user_id: inserted_mod.id,
510       locked: Some(true),
511       when_: inserted_mod_lock_post.when_,
512     };
513
514     // comment
515
516     let mod_remove_comment_form = ModRemoveCommentForm {
517       mod_user_id: inserted_mod.id,
518       comment_id: inserted_comment.id,
519       reason: None,
520       removed: None,
521     };
522     let inserted_mod_remove_comment = ModRemoveComment::create(&conn, &mod_remove_comment_form).unwrap();
523     let read_moderator_remove_comment = ModRemoveComment::read(&conn, inserted_mod_remove_comment.id).unwrap();
524     let expected_moderator_remove_comment = ModRemoveComment {
525       id: inserted_mod_remove_comment.id,
526       comment_id: inserted_comment.id,
527       mod_user_id: inserted_mod.id,
528       reason: None,
529       removed: Some(true),
530       when_: inserted_mod_remove_comment.when_,
531     };
532
533     // community
534
535     let mod_remove_community_form = ModRemoveCommunityForm {
536       mod_user_id: inserted_mod.id,
537       community_id: inserted_community.id,
538       reason: None,
539       removed: None,
540       expires: None,
541     };
542     let inserted_mod_remove_community = ModRemoveCommunity::create(&conn, &mod_remove_community_form).unwrap();
543     let read_moderator_remove_community = ModRemoveCommunity::read(&conn, inserted_mod_remove_community.id).unwrap();
544     let expected_moderator_remove_community = ModRemoveCommunity {
545       id: inserted_mod_remove_community.id,
546       community_id: inserted_community.id,
547       mod_user_id: inserted_mod.id,
548       reason: None,
549       removed: Some(true),
550       expires: None,
551       when_: inserted_mod_remove_community.when_,
552     };
553
554     // ban from community
555
556     let mod_ban_from_community_form = ModBanFromCommunityForm {
557       mod_user_id: inserted_mod.id,
558       other_user_id: inserted_user.id,
559       community_id: inserted_community.id,
560       reason: None,
561       banned: None,
562       expires: None,
563     };
564     let inserted_mod_ban_from_community = ModBanFromCommunity::create(&conn, &mod_ban_from_community_form).unwrap();
565     let read_moderator_ban_from_community = ModBanFromCommunity::read(&conn, inserted_mod_ban_from_community.id).unwrap();
566     let expected_moderator_ban_from_community = ModBanFromCommunity {
567       id: inserted_mod_ban_from_community.id,
568       community_id: inserted_community.id,
569       mod_user_id: inserted_mod.id,
570       other_user_id: inserted_user.id,
571       reason: None,
572       banned: Some(true),
573       expires: None,
574       when_: inserted_mod_ban_from_community.when_,
575     };
576
577     // ban
578
579     let mod_ban_form = ModBanForm {
580       mod_user_id: inserted_mod.id,
581       other_user_id: inserted_user.id,
582       reason: None,
583       banned: None,
584       expires: None,
585     };
586     let inserted_mod_ban = ModBan::create(&conn, &mod_ban_form).unwrap();
587     let read_moderator_ban = ModBan::read(&conn, inserted_mod_ban.id).unwrap();
588     let expected_moderator_ban = ModBan {
589       id: inserted_mod_ban.id,
590       mod_user_id: inserted_mod.id,
591       other_user_id: inserted_user.id,
592       reason: None,
593       banned: Some(true),
594       expires: None,
595       when_: inserted_mod_ban.when_,
596     };
597
598     // mod add community
599
600     let mod_add_community_form = ModAddCommunityForm {
601       mod_user_id: inserted_mod.id,
602       other_user_id: inserted_user.id,
603       community_id: inserted_community.id,
604       removed: None,
605     };
606     let inserted_mod_add_community = ModAddCommunity::create(&conn, &mod_add_community_form).unwrap();
607     let read_moderator_add_community = ModAddCommunity::read(&conn, inserted_mod_add_community.id).unwrap();
608     let expected_moderator_add_community = ModAddCommunity {
609       id: inserted_mod_add_community.id,
610       community_id: inserted_community.id,
611       mod_user_id: inserted_mod.id,
612       other_user_id: inserted_user.id,
613       removed: Some(false),
614       when_: inserted_mod_add_community.when_,
615     };
616
617     // mod add
618
619     let mod_add_form = ModAddForm {
620       mod_user_id: inserted_mod.id,
621       other_user_id: inserted_user.id,
622       removed: None,
623     };
624     let inserted_mod_add = ModAdd::create(&conn, &mod_add_form).unwrap();
625     let read_moderator_add = ModAdd::read(&conn, inserted_mod_add.id).unwrap();
626     let expected_moderator_add = ModAdd {
627       id: inserted_mod_add.id,
628       mod_user_id: inserted_mod.id,
629       other_user_id: inserted_user.id,
630       removed: Some(false),
631       when_: inserted_mod_add.when_,
632     };
633
634     ModRemovePost::delete(&conn, inserted_mod_remove_post.id).unwrap();
635     ModLockPost::delete(&conn, inserted_mod_lock_post.id).unwrap();
636     ModRemoveComment::delete(&conn, inserted_mod_remove_comment.id).unwrap();
637     ModRemoveCommunity::delete(&conn, inserted_mod_remove_community.id).unwrap();
638     ModBanFromCommunity::delete(&conn, inserted_mod_ban_from_community.id).unwrap();
639     ModBan::delete(&conn, inserted_mod_ban.id).unwrap();
640     ModAddCommunity::delete(&conn, inserted_mod_add_community.id).unwrap();
641     ModAdd::delete(&conn, inserted_mod_add.id).unwrap();
642
643     Comment::delete(&conn, inserted_comment.id).unwrap();
644     Post::delete(&conn, inserted_post.id).unwrap();
645     Community::delete(&conn, inserted_community.id).unwrap();
646     User_::delete(&conn, inserted_user.id).unwrap();
647     User_::delete(&conn, inserted_mod.id).unwrap();
648
649     assert_eq!(expected_moderator_remove_post, read_moderator_remove_post);
650     assert_eq!(expected_moderator_lock_post, read_moderator_lock_post);
651     assert_eq!(expected_moderator_remove_comment, read_moderator_remove_comment);
652     assert_eq!(expected_moderator_remove_community, read_moderator_remove_community);
653     assert_eq!(expected_moderator_ban_from_community, read_moderator_ban_from_community);
654     assert_eq!(expected_moderator_ban, read_moderator_ban);
655     assert_eq!(expected_moderator_add_community, read_moderator_add_community);
656     assert_eq!(expected_moderator_add, read_moderator_add);
657   }
658 }