]> Untitled Git - lemmy.git/blob - server/src/db/moderator.rs
Adding emoji support
[lemmy.git] / server / src / db / moderator.rs
1 use 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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     };
417
418     let inserted_mod = User_::create(&conn, &new_mod).unwrap();
419
420     let new_user = UserForm {
421       name: "jim2".into(),
422       fedi_name: "rrf".into(),
423       preferred_username: None,
424       password_encrypted: "nope".into(),
425       email: None,
426       admin: false,
427       banned: false,
428       updated: None
429     };
430
431     let inserted_user = User_::create(&conn, &new_user).unwrap();
432
433     let new_community = CommunityForm {
434       name: "mod_community".to_string(),
435       title: "nada".to_owned(),
436       description: None,
437       category_id: 1,
438       creator_id: inserted_user.id,
439       removed: None,
440       deleted: None,
441       updated: None
442     };
443
444     let inserted_community = Community::create(&conn, &new_community).unwrap();
445     
446     let new_post = PostForm {
447       name: "A test post thweep".into(),
448       url: None,
449       body: None,
450       creator_id: inserted_user.id,
451       community_id: inserted_community.id,
452       removed: None,
453       deleted: None,
454       locked: None,
455       updated: None
456     };
457
458     let inserted_post = Post::create(&conn, &new_post).unwrap();
459
460     let comment_form = CommentForm {
461       content: "A test comment".into(),
462       creator_id: inserted_user.id,
463       post_id: inserted_post.id,
464       removed: None,
465       deleted: None,
466       read: None,
467       parent_id: None,
468       updated: None
469     };
470
471     let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
472
473     // Now the actual tests
474
475     // remove post
476     let mod_remove_post_form = ModRemovePostForm {
477       mod_user_id: inserted_mod.id,
478       post_id: inserted_post.id,
479       reason: None,
480       removed: None,
481     };
482     let inserted_mod_remove_post = ModRemovePost::create(&conn, &mod_remove_post_form).unwrap();
483     let read_moderator_remove_post = ModRemovePost::read(&conn, inserted_mod_remove_post.id).unwrap();
484     let expected_moderator_remove_post = ModRemovePost {
485       id: inserted_mod_remove_post.id,
486       post_id: inserted_post.id,
487       mod_user_id: inserted_mod.id,
488       reason: None,
489       removed: Some(true),
490       when_: inserted_mod_remove_post.when_,
491     };
492
493     // lock post
494
495     let mod_lock_post_form = ModLockPostForm {
496       mod_user_id: inserted_mod.id,
497       post_id: inserted_post.id,
498       locked: None,
499     };
500     let inserted_mod_lock_post = ModLockPost::create(&conn, &mod_lock_post_form).unwrap();
501     let read_moderator_lock_post = ModLockPost::read(&conn, inserted_mod_lock_post.id).unwrap();
502     let expected_moderator_lock_post = ModLockPost {
503       id: inserted_mod_lock_post.id,
504       post_id: inserted_post.id,
505       mod_user_id: inserted_mod.id,
506       locked: Some(true),
507       when_: inserted_mod_lock_post.when_,
508     };
509
510     // comment
511
512     let mod_remove_comment_form = ModRemoveCommentForm {
513       mod_user_id: inserted_mod.id,
514       comment_id: inserted_comment.id,
515       reason: None,
516       removed: None,
517     };
518     let inserted_mod_remove_comment = ModRemoveComment::create(&conn, &mod_remove_comment_form).unwrap();
519     let read_moderator_remove_comment = ModRemoveComment::read(&conn, inserted_mod_remove_comment.id).unwrap();
520     let expected_moderator_remove_comment = ModRemoveComment {
521       id: inserted_mod_remove_comment.id,
522       comment_id: inserted_comment.id,
523       mod_user_id: inserted_mod.id,
524       reason: None,
525       removed: Some(true),
526       when_: inserted_mod_remove_comment.when_,
527     };
528
529     // community
530
531     let mod_remove_community_form = ModRemoveCommunityForm {
532       mod_user_id: inserted_mod.id,
533       community_id: inserted_community.id,
534       reason: None,
535       removed: None,
536       expires: None,
537     };
538     let inserted_mod_remove_community = ModRemoveCommunity::create(&conn, &mod_remove_community_form).unwrap();
539     let read_moderator_remove_community = ModRemoveCommunity::read(&conn, inserted_mod_remove_community.id).unwrap();
540     let expected_moderator_remove_community = ModRemoveCommunity {
541       id: inserted_mod_remove_community.id,
542       community_id: inserted_community.id,
543       mod_user_id: inserted_mod.id,
544       reason: None,
545       removed: Some(true),
546       expires: None,
547       when_: inserted_mod_remove_community.when_,
548     };
549
550     // ban from community
551
552     let mod_ban_from_community_form = ModBanFromCommunityForm {
553       mod_user_id: inserted_mod.id,
554       other_user_id: inserted_user.id,
555       community_id: inserted_community.id,
556       reason: None,
557       banned: None,
558       expires: None,
559     };
560     let inserted_mod_ban_from_community = ModBanFromCommunity::create(&conn, &mod_ban_from_community_form).unwrap();
561     let read_moderator_ban_from_community = ModBanFromCommunity::read(&conn, inserted_mod_ban_from_community.id).unwrap();
562     let expected_moderator_ban_from_community = ModBanFromCommunity {
563       id: inserted_mod_ban_from_community.id,
564       community_id: inserted_community.id,
565       mod_user_id: inserted_mod.id,
566       other_user_id: inserted_user.id,
567       reason: None,
568       banned: Some(true),
569       expires: None,
570       when_: inserted_mod_ban_from_community.when_,
571     };
572
573     // ban
574
575     let mod_ban_form = ModBanForm {
576       mod_user_id: inserted_mod.id,
577       other_user_id: inserted_user.id,
578       reason: None,
579       banned: None,
580       expires: None,
581     };
582     let inserted_mod_ban = ModBan::create(&conn, &mod_ban_form).unwrap();
583     let read_moderator_ban = ModBan::read(&conn, inserted_mod_ban.id).unwrap();
584     let expected_moderator_ban = ModBan {
585       id: inserted_mod_ban.id,
586       mod_user_id: inserted_mod.id,
587       other_user_id: inserted_user.id,
588       reason: None,
589       banned: Some(true),
590       expires: None,
591       when_: inserted_mod_ban.when_,
592     };
593
594     // mod add community
595
596     let mod_add_community_form = ModAddCommunityForm {
597       mod_user_id: inserted_mod.id,
598       other_user_id: inserted_user.id,
599       community_id: inserted_community.id,
600       removed: None,
601     };
602     let inserted_mod_add_community = ModAddCommunity::create(&conn, &mod_add_community_form).unwrap();
603     let read_moderator_add_community = ModAddCommunity::read(&conn, inserted_mod_add_community.id).unwrap();
604     let expected_moderator_add_community = ModAddCommunity {
605       id: inserted_mod_add_community.id,
606       community_id: inserted_community.id,
607       mod_user_id: inserted_mod.id,
608       other_user_id: inserted_user.id,
609       removed: Some(false),
610       when_: inserted_mod_add_community.when_,
611     };
612
613     // mod add
614
615     let mod_add_form = ModAddForm {
616       mod_user_id: inserted_mod.id,
617       other_user_id: inserted_user.id,
618       removed: None,
619     };
620     let inserted_mod_add = ModAdd::create(&conn, &mod_add_form).unwrap();
621     let read_moderator_add = ModAdd::read(&conn, inserted_mod_add.id).unwrap();
622     let expected_moderator_add = ModAdd {
623       id: inserted_mod_add.id,
624       mod_user_id: inserted_mod.id,
625       other_user_id: inserted_user.id,
626       removed: Some(false),
627       when_: inserted_mod_add.when_,
628     };
629
630     ModRemovePost::delete(&conn, inserted_mod_remove_post.id).unwrap();
631     ModLockPost::delete(&conn, inserted_mod_lock_post.id).unwrap();
632     ModRemoveComment::delete(&conn, inserted_mod_remove_comment.id).unwrap();
633     ModRemoveCommunity::delete(&conn, inserted_mod_remove_community.id).unwrap();
634     ModBanFromCommunity::delete(&conn, inserted_mod_ban_from_community.id).unwrap();
635     ModBan::delete(&conn, inserted_mod_ban.id).unwrap();
636     ModAddCommunity::delete(&conn, inserted_mod_add_community.id).unwrap();
637     ModAdd::delete(&conn, inserted_mod_add.id).unwrap();
638
639     Comment::delete(&conn, inserted_comment.id).unwrap();
640     Post::delete(&conn, inserted_post.id).unwrap();
641     Community::delete(&conn, inserted_community.id).unwrap();
642     User_::delete(&conn, inserted_user.id).unwrap();
643     User_::delete(&conn, inserted_mod.id).unwrap();
644
645     assert_eq!(expected_moderator_remove_post, read_moderator_remove_post);
646     assert_eq!(expected_moderator_lock_post, read_moderator_lock_post);
647     assert_eq!(expected_moderator_remove_comment, read_moderator_remove_comment);
648     assert_eq!(expected_moderator_remove_community, read_moderator_remove_community);
649     assert_eq!(expected_moderator_ban_from_community, read_moderator_ban_from_community);
650     assert_eq!(expected_moderator_ban, read_moderator_ban);
651     assert_eq!(expected_moderator_add_community, read_moderator_add_community);
652     assert_eq!(expected_moderator_add, read_moderator_add);
653   }
654 }