]> Untitled Git - lemmy.git/blob - crates/db_views/src/comment_view.rs
Fix problem where actors can have empty public key (fixes #2347) (#2348)
[lemmy.git] / crates / db_views / src / comment_view.rs
1 use crate::structs::CommentView;
2 use diesel::{
3   dsl::*,
4   result::{Error, Error::QueryBuilderError},
5   *,
6 };
7 use lemmy_db_schema::{
8   aggregates::structs::CommentAggregates,
9   newtypes::{CommentId, CommunityId, DbUrl, PersonId, PostId},
10   schema::{
11     comment,
12     comment_aggregates,
13     comment_alias_1,
14     comment_like,
15     comment_saved,
16     community,
17     community_block,
18     community_follower,
19     community_person_ban,
20     person,
21     person_alias_1,
22     person_block,
23     post,
24   },
25   source::{
26     comment::{Comment, CommentAlias1, CommentSaved},
27     community::{Community, CommunityFollower, CommunityPersonBan, CommunitySafe},
28     person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1},
29     person_block::PersonBlock,
30     post::Post,
31   },
32   traits::{MaybeOptional, ToSafe, ViewToVec},
33   utils::{functions::hot_rank, fuzzy_search, limit_and_offset_unlimited},
34   ListingType,
35   SortType,
36 };
37
38 type CommentViewTuple = (
39   Comment,
40   PersonSafe,
41   Option<CommentAlias1>,
42   Option<PersonSafeAlias1>,
43   Post,
44   CommunitySafe,
45   CommentAggregates,
46   Option<CommunityPersonBan>,
47   Option<CommunityFollower>,
48   Option<CommentSaved>,
49   Option<PersonBlock>,
50   Option<i16>,
51 );
52
53 impl CommentView {
54   pub fn read(
55     conn: &PgConnection,
56     comment_id: CommentId,
57     my_person_id: Option<PersonId>,
58   ) -> Result<Self, Error> {
59     // The left join below will return None in this case
60     let person_id_join = my_person_id.unwrap_or(PersonId(-1));
61
62     let (
63       comment,
64       creator,
65       _parent_comment,
66       recipient,
67       post,
68       community,
69       counts,
70       creator_banned_from_community,
71       follower,
72       saved,
73       creator_blocked,
74       comment_like,
75     ) = comment::table
76       .find(comment_id)
77       .inner_join(person::table)
78       // recipient here
79       .left_join(comment_alias_1::table.on(comment_alias_1::id.nullable().eq(comment::parent_id)))
80       .left_join(person_alias_1::table.on(person_alias_1::id.eq(comment_alias_1::creator_id)))
81       .inner_join(post::table)
82       .inner_join(community::table.on(post::community_id.eq(community::id)))
83       .inner_join(comment_aggregates::table)
84       .left_join(
85         community_person_ban::table.on(
86           community::id
87             .eq(community_person_ban::community_id)
88             .and(community_person_ban::person_id.eq(comment::creator_id))
89             .and(
90               community_person_ban::expires
91                 .is_null()
92                 .or(community_person_ban::expires.gt(now)),
93             ),
94         ),
95       )
96       .left_join(
97         community_follower::table.on(
98           post::community_id
99             .eq(community_follower::community_id)
100             .and(community_follower::person_id.eq(person_id_join)),
101         ),
102       )
103       .left_join(
104         comment_saved::table.on(
105           comment::id
106             .eq(comment_saved::comment_id)
107             .and(comment_saved::person_id.eq(person_id_join)),
108         ),
109       )
110       .left_join(
111         person_block::table.on(
112           comment::creator_id
113             .eq(person_block::target_id)
114             .and(person_block::person_id.eq(person_id_join)),
115         ),
116       )
117       .left_join(
118         comment_like::table.on(
119           comment::id
120             .eq(comment_like::comment_id)
121             .and(comment_like::person_id.eq(person_id_join)),
122         ),
123       )
124       .select((
125         comment::all_columns,
126         Person::safe_columns_tuple(),
127         comment_alias_1::all_columns.nullable(),
128         PersonAlias1::safe_columns_tuple().nullable(),
129         post::all_columns,
130         Community::safe_columns_tuple(),
131         comment_aggregates::all_columns,
132         community_person_ban::all_columns.nullable(),
133         community_follower::all_columns.nullable(),
134         comment_saved::all_columns.nullable(),
135         person_block::all_columns.nullable(),
136         comment_like::score.nullable(),
137       ))
138       .first::<CommentViewTuple>(conn)?;
139
140     // If a person is given, then my_vote, if None, should be 0, not null
141     // Necessary to differentiate between other person's votes
142     let my_vote = if my_person_id.is_some() && comment_like.is_none() {
143       Some(0)
144     } else {
145       comment_like
146     };
147
148     Ok(CommentView {
149       comment,
150       recipient,
151       post,
152       creator,
153       community,
154       counts,
155       creator_banned_from_community: creator_banned_from_community.is_some(),
156       subscribed: CommunityFollower::to_subscribed_type(&follower),
157       saved: saved.is_some(),
158       creator_blocked: creator_blocked.is_some(),
159       my_vote,
160     })
161   }
162
163   /// Gets the recipient person id.
164   /// If there is no parent comment, its the post creator
165   pub fn get_recipient_id(&self) -> PersonId {
166     match &self.recipient {
167       Some(parent_commenter) => parent_commenter.id,
168       None => self.post.creator_id,
169     }
170   }
171
172   /// Gets the number of unread replies
173   pub fn get_unread_replies(conn: &PgConnection, my_person_id: PersonId) -> Result<i64, Error> {
174     use diesel::dsl::*;
175
176     comment::table
177       // recipient here
178       .left_join(comment_alias_1::table.on(comment_alias_1::id.nullable().eq(comment::parent_id)))
179       .left_join(person_alias_1::table.on(person_alias_1::id.eq(comment_alias_1::creator_id)))
180       .inner_join(post::table)
181       .inner_join(community::table.on(post::community_id.eq(community::id)))
182       .left_join(
183         person_block::table.on(
184           comment::creator_id
185             .eq(person_block::target_id)
186             .and(person_block::person_id.eq(my_person_id)),
187         ),
188       )
189       .left_join(
190         community_block::table.on(
191           community::id
192             .eq(community_block::community_id)
193             .and(community_block::person_id.eq(my_person_id)),
194         ),
195       )
196       .filter(person_alias_1::id.eq(my_person_id)) // Gets the comment replies
197       .or_filter(
198         comment::parent_id
199           .is_null()
200           .and(post::creator_id.eq(my_person_id)),
201       ) // Gets the top level replies
202       .filter(comment::read.eq(false))
203       .filter(comment::deleted.eq(false))
204       .filter(comment::removed.eq(false))
205       // Don't show blocked communities or persons
206       .filter(community_block::person_id.is_null())
207       .filter(person_block::person_id.is_null())
208       .select(count(comment::id))
209       .first::<i64>(conn)
210   }
211 }
212
213 pub struct CommentQueryBuilder<'a> {
214   conn: &'a PgConnection,
215   listing_type: Option<ListingType>,
216   sort: Option<SortType>,
217   community_id: Option<CommunityId>,
218   community_actor_id: Option<DbUrl>,
219   post_id: Option<PostId>,
220   creator_id: Option<PersonId>,
221   recipient_id: Option<PersonId>,
222   my_person_id: Option<PersonId>,
223   search_term: Option<String>,
224   saved_only: Option<bool>,
225   unread_only: Option<bool>,
226   show_bot_accounts: Option<bool>,
227   page: Option<i64>,
228   limit: Option<i64>,
229 }
230
231 impl<'a> CommentQueryBuilder<'a> {
232   pub fn create(conn: &'a PgConnection) -> Self {
233     CommentQueryBuilder {
234       conn,
235       listing_type: None,
236       sort: None,
237       community_id: None,
238       community_actor_id: None,
239       post_id: None,
240       creator_id: None,
241       recipient_id: None,
242       my_person_id: None,
243       search_term: None,
244       saved_only: None,
245       unread_only: None,
246       show_bot_accounts: None,
247       page: None,
248       limit: None,
249     }
250   }
251
252   pub fn listing_type<T: MaybeOptional<ListingType>>(mut self, listing_type: T) -> Self {
253     self.listing_type = listing_type.get_optional();
254     self
255   }
256
257   pub fn sort<T: MaybeOptional<SortType>>(mut self, sort: T) -> Self {
258     self.sort = sort.get_optional();
259     self
260   }
261
262   pub fn post_id<T: MaybeOptional<PostId>>(mut self, post_id: T) -> Self {
263     self.post_id = post_id.get_optional();
264     self
265   }
266
267   pub fn creator_id<T: MaybeOptional<PersonId>>(mut self, creator_id: T) -> Self {
268     self.creator_id = creator_id.get_optional();
269     self
270   }
271
272   pub fn recipient_id<T: MaybeOptional<PersonId>>(mut self, recipient_id: T) -> Self {
273     self.recipient_id = recipient_id.get_optional();
274     self
275   }
276
277   pub fn community_id<T: MaybeOptional<CommunityId>>(mut self, community_id: T) -> Self {
278     self.community_id = community_id.get_optional();
279     self
280   }
281
282   pub fn my_person_id<T: MaybeOptional<PersonId>>(mut self, my_person_id: T) -> Self {
283     self.my_person_id = my_person_id.get_optional();
284     self
285   }
286
287   pub fn community_actor_id<T: MaybeOptional<DbUrl>>(mut self, community_actor_id: T) -> Self {
288     self.community_actor_id = community_actor_id.get_optional();
289     self
290   }
291
292   pub fn search_term<T: MaybeOptional<String>>(mut self, search_term: T) -> Self {
293     self.search_term = search_term.get_optional();
294     self
295   }
296
297   pub fn saved_only<T: MaybeOptional<bool>>(mut self, saved_only: T) -> Self {
298     self.saved_only = saved_only.get_optional();
299     self
300   }
301
302   pub fn unread_only<T: MaybeOptional<bool>>(mut self, unread_only: T) -> Self {
303     self.unread_only = unread_only.get_optional();
304     self
305   }
306
307   pub fn show_bot_accounts<T: MaybeOptional<bool>>(mut self, show_bot_accounts: T) -> Self {
308     self.show_bot_accounts = show_bot_accounts.get_optional();
309     self
310   }
311
312   pub fn page<T: MaybeOptional<i64>>(mut self, page: T) -> Self {
313     self.page = page.get_optional();
314     self
315   }
316
317   pub fn limit<T: MaybeOptional<i64>>(mut self, limit: T) -> Self {
318     self.limit = limit.get_optional();
319     self
320   }
321
322   pub fn list(self) -> Result<Vec<CommentView>, Error> {
323     use diesel::dsl::*;
324
325     // The left join below will return None in this case
326     let person_id_join = self.my_person_id.unwrap_or(PersonId(-1));
327
328     let mut query = comment::table
329       .inner_join(person::table)
330       // recipient here
331       .left_join(comment_alias_1::table.on(comment_alias_1::id.nullable().eq(comment::parent_id)))
332       .left_join(person_alias_1::table.on(person_alias_1::id.eq(comment_alias_1::creator_id)))
333       .inner_join(post::table)
334       .inner_join(community::table.on(post::community_id.eq(community::id)))
335       .inner_join(comment_aggregates::table)
336       .left_join(
337         community_person_ban::table.on(
338           community::id
339             .eq(community_person_ban::community_id)
340             .and(community_person_ban::person_id.eq(comment::creator_id))
341             .and(
342               community_person_ban::expires
343                 .is_null()
344                 .or(community_person_ban::expires.gt(now)),
345             ),
346         ),
347       )
348       .left_join(
349         community_follower::table.on(
350           post::community_id
351             .eq(community_follower::community_id)
352             .and(community_follower::person_id.eq(person_id_join)),
353         ),
354       )
355       .left_join(
356         comment_saved::table.on(
357           comment::id
358             .eq(comment_saved::comment_id)
359             .and(comment_saved::person_id.eq(person_id_join)),
360         ),
361       )
362       .left_join(
363         person_block::table.on(
364           comment::creator_id
365             .eq(person_block::target_id)
366             .and(person_block::person_id.eq(person_id_join)),
367         ),
368       )
369       .left_join(
370         community_block::table.on(
371           community::id
372             .eq(community_block::community_id)
373             .and(community_block::person_id.eq(person_id_join)),
374         ),
375       )
376       .left_join(
377         comment_like::table.on(
378           comment::id
379             .eq(comment_like::comment_id)
380             .and(comment_like::person_id.eq(person_id_join)),
381         ),
382       )
383       .select((
384         comment::all_columns,
385         Person::safe_columns_tuple(),
386         comment_alias_1::all_columns.nullable(),
387         PersonAlias1::safe_columns_tuple().nullable(),
388         post::all_columns,
389         Community::safe_columns_tuple(),
390         comment_aggregates::all_columns,
391         community_person_ban::all_columns.nullable(),
392         community_follower::all_columns.nullable(),
393         comment_saved::all_columns.nullable(),
394         person_block::all_columns.nullable(),
395         comment_like::score.nullable(),
396       ))
397       .into_boxed();
398
399     // The replies
400     if let Some(recipient_id) = self.recipient_id {
401       query = query
402         // TODO needs lots of testing
403         .filter(person_alias_1::id.eq(recipient_id)) // Gets the comment replies
404         .or_filter(
405           comment::parent_id
406             .is_null()
407             .and(post::creator_id.eq(recipient_id)),
408         ) // Gets the top level replies
409         .filter(comment::deleted.eq(false))
410         .filter(comment::removed.eq(false));
411     }
412
413     if self.unread_only.unwrap_or(false) {
414       query = query.filter(comment::read.eq(false));
415     }
416
417     if let Some(creator_id) = self.creator_id {
418       query = query.filter(comment::creator_id.eq(creator_id));
419     };
420
421     if let Some(post_id) = self.post_id {
422       query = query.filter(comment::post_id.eq(post_id));
423     };
424
425     if let Some(search_term) = self.search_term {
426       query = query.filter(comment::content.ilike(fuzzy_search(&search_term)));
427     };
428
429     if let Some(listing_type) = self.listing_type {
430       match listing_type {
431         ListingType::Subscribed => {
432           query = query.filter(community_follower::person_id.is_not_null())
433         } // TODO could be this: and(community_follower::person_id.eq(person_id_join)),
434         ListingType::Local => {
435           query = query.filter(community::local.eq(true)).filter(
436             community::hidden
437               .eq(false)
438               .or(community_follower::person_id.eq(person_id_join)),
439           )
440         }
441         ListingType::All => {
442           query = query.filter(
443             community::hidden
444               .eq(false)
445               .or(community_follower::person_id.eq(person_id_join)),
446           )
447         }
448         ListingType::Community => {
449           if self.community_actor_id.is_none() && self.community_id.is_none() {
450             return Err(QueryBuilderError("No community actor or id given".into()));
451           } else {
452             if let Some(community_id) = self.community_id {
453               query = query.filter(post::community_id.eq(community_id));
454             }
455
456             if let Some(community_actor_id) = self.community_actor_id {
457               query = query.filter(community::actor_id.eq(community_actor_id))
458             }
459           }
460         }
461       }
462     };
463
464     if self.saved_only.unwrap_or(false) {
465       query = query.filter(comment_saved::id.is_not_null());
466     }
467
468     if !self.show_bot_accounts.unwrap_or(true) {
469       query = query.filter(person::bot_account.eq(false));
470     };
471
472     query = match self.sort.unwrap_or(SortType::New) {
473       SortType::Hot | SortType::Active => query
474         .order_by(hot_rank(comment_aggregates::score, comment_aggregates::published).desc())
475         .then_order_by(comment_aggregates::published.desc()),
476       SortType::New | SortType::MostComments | SortType::NewComments => {
477         query.order_by(comment::published.desc())
478       }
479       SortType::TopAll => query.order_by(comment_aggregates::score.desc()),
480       SortType::TopYear => query
481         .filter(comment::published.gt(now - 1.years()))
482         .order_by(comment_aggregates::score.desc()),
483       SortType::TopMonth => query
484         .filter(comment::published.gt(now - 1.months()))
485         .order_by(comment_aggregates::score.desc()),
486       SortType::TopWeek => query
487         .filter(comment::published.gt(now - 1.weeks()))
488         .order_by(comment_aggregates::score.desc()),
489       SortType::TopDay => query
490         .filter(comment::published.gt(now - 1.days()))
491         .order_by(comment_aggregates::score.desc()),
492     };
493
494     // Don't show blocked communities or persons
495     if self.my_person_id.is_some() {
496       query = query.filter(community_block::person_id.is_null());
497       query = query.filter(person_block::person_id.is_null());
498     }
499
500     // Don't use the regular error-checking one, many more comments must ofter be fetched.
501     let (limit, offset) = limit_and_offset_unlimited(self.page, self.limit);
502
503     // Note: deleted and removed comments are done on the front side
504     let res = query
505       .limit(limit)
506       .offset(offset)
507       .load::<CommentViewTuple>(self.conn)?;
508
509     Ok(CommentView::from_tuple_to_vec(res))
510   }
511 }
512
513 impl ViewToVec for CommentView {
514   type DbTuple = CommentViewTuple;
515   fn from_tuple_to_vec(items: Vec<Self::DbTuple>) -> Vec<Self> {
516     items
517       .iter()
518       .map(|a| Self {
519         comment: a.0.to_owned(),
520         creator: a.1.to_owned(),
521         recipient: a.3.to_owned(),
522         post: a.4.to_owned(),
523         community: a.5.to_owned(),
524         counts: a.6.to_owned(),
525         creator_banned_from_community: a.7.is_some(),
526         subscribed: CommunityFollower::to_subscribed_type(&a.8),
527         saved: a.9.is_some(),
528         creator_blocked: a.10.is_some(),
529         my_vote: a.11,
530       })
531       .collect::<Vec<Self>>()
532   }
533 }
534
535 #[cfg(test)]
536 mod tests {
537   use crate::comment_view::*;
538   use lemmy_db_schema::{
539     aggregates::structs::CommentAggregates,
540     source::{comment::*, community::*, person::*, person_block::PersonBlockForm, post::*},
541     traits::{Blockable, Crud, Likeable},
542     utils::establish_unpooled_connection,
543     SubscribedType,
544   };
545   use serial_test::serial;
546
547   #[test]
548   #[serial]
549   fn test_crud() {
550     let conn = establish_unpooled_connection();
551
552     let new_person = PersonForm {
553       name: "timmy".into(),
554       public_key: Some("pubkey".to_string()),
555       ..PersonForm::default()
556     };
557
558     let inserted_person = Person::create(&conn, &new_person).unwrap();
559
560     let new_person_2 = PersonForm {
561       name: "sara".into(),
562       public_key: Some("pubkey".to_string()),
563       ..PersonForm::default()
564     };
565
566     let inserted_person_2 = Person::create(&conn, &new_person_2).unwrap();
567
568     let new_community = CommunityForm {
569       name: "test community 5".to_string(),
570       title: "nada".to_owned(),
571       public_key: Some("pubkey".to_string()),
572       ..CommunityForm::default()
573     };
574
575     let inserted_community = Community::create(&conn, &new_community).unwrap();
576
577     let new_post = PostForm {
578       name: "A test post 2".into(),
579       creator_id: inserted_person.id,
580       community_id: inserted_community.id,
581       ..PostForm::default()
582     };
583
584     let inserted_post = Post::create(&conn, &new_post).unwrap();
585
586     let comment_form = CommentForm {
587       content: "A test comment 32".into(),
588       creator_id: inserted_person.id,
589       post_id: inserted_post.id,
590       ..CommentForm::default()
591     };
592
593     let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
594
595     let comment_form_2 = CommentForm {
596       content: "A test blocked comment".into(),
597       creator_id: inserted_person_2.id,
598       post_id: inserted_post.id,
599       parent_id: Some(inserted_comment.id),
600       ..CommentForm::default()
601     };
602
603     let inserted_comment_2 = Comment::create(&conn, &comment_form_2).unwrap();
604
605     let timmy_blocks_sara_form = PersonBlockForm {
606       person_id: inserted_person.id,
607       target_id: inserted_person_2.id,
608     };
609
610     let inserted_block = PersonBlock::block(&conn, &timmy_blocks_sara_form).unwrap();
611
612     let expected_block = PersonBlock {
613       id: inserted_block.id,
614       person_id: inserted_person.id,
615       target_id: inserted_person_2.id,
616       published: inserted_block.published,
617     };
618
619     assert_eq!(expected_block, inserted_block);
620
621     let comment_like_form = CommentLikeForm {
622       comment_id: inserted_comment.id,
623       post_id: inserted_post.id,
624       person_id: inserted_person.id,
625       score: 1,
626     };
627
628     let _inserted_comment_like = CommentLike::like(&conn, &comment_like_form).unwrap();
629
630     let agg = CommentAggregates::read(&conn, inserted_comment.id).unwrap();
631
632     let expected_comment_view_no_person = CommentView {
633       creator_banned_from_community: false,
634       my_vote: None,
635       subscribed: SubscribedType::NotSubscribed,
636       saved: false,
637       creator_blocked: false,
638       comment: Comment {
639         id: inserted_comment.id,
640         content: "A test comment 32".into(),
641         creator_id: inserted_person.id,
642         post_id: inserted_post.id,
643         parent_id: None,
644         removed: false,
645         deleted: false,
646         read: false,
647         published: inserted_comment.published,
648         ap_id: inserted_comment.ap_id,
649         updated: None,
650         local: true,
651       },
652       creator: PersonSafe {
653         id: inserted_person.id,
654         name: "timmy".into(),
655         display_name: None,
656         published: inserted_person.published,
657         avatar: None,
658         actor_id: inserted_person.actor_id.to_owned(),
659         local: true,
660         banned: false,
661         deleted: false,
662         admin: false,
663         bot_account: false,
664         bio: None,
665         banner: None,
666         updated: None,
667         inbox_url: inserted_person.inbox_url.to_owned(),
668         shared_inbox_url: None,
669         matrix_user_id: None,
670         ban_expires: None,
671       },
672       recipient: None,
673       post: Post {
674         id: inserted_post.id,
675         name: inserted_post.name.to_owned(),
676         creator_id: inserted_person.id,
677         url: None,
678         body: None,
679         published: inserted_post.published,
680         updated: None,
681         community_id: inserted_community.id,
682         removed: false,
683         deleted: false,
684         locked: false,
685         stickied: false,
686         nsfw: false,
687         embed_title: None,
688         embed_description: None,
689         embed_video_url: None,
690         thumbnail_url: None,
691         ap_id: inserted_post.ap_id.to_owned(),
692         local: true,
693       },
694       community: CommunitySafe {
695         id: inserted_community.id,
696         name: "test community 5".to_string(),
697         icon: None,
698         removed: false,
699         deleted: false,
700         nsfw: false,
701         actor_id: inserted_community.actor_id.to_owned(),
702         local: true,
703         title: "nada".to_owned(),
704         description: None,
705         updated: None,
706         banner: None,
707         hidden: false,
708         posting_restricted_to_mods: false,
709         published: inserted_community.published,
710       },
711       counts: CommentAggregates {
712         id: agg.id,
713         comment_id: inserted_comment.id,
714         score: 1,
715         upvotes: 1,
716         downvotes: 0,
717         published: agg.published,
718       },
719     };
720
721     let mut expected_comment_view_with_person = expected_comment_view_no_person.to_owned();
722     expected_comment_view_with_person.my_vote = Some(1);
723
724     let read_comment_views_no_person = CommentQueryBuilder::create(&conn)
725       .post_id(inserted_post.id)
726       .list()
727       .unwrap();
728
729     let read_comment_views_with_person = CommentQueryBuilder::create(&conn)
730       .post_id(inserted_post.id)
731       .my_person_id(inserted_person.id)
732       .list()
733       .unwrap();
734
735     let read_comment_from_blocked_person =
736       CommentView::read(&conn, inserted_comment_2.id, Some(inserted_person.id)).unwrap();
737
738     let like_removed = CommentLike::remove(&conn, inserted_person.id, inserted_comment.id).unwrap();
739     let num_deleted = Comment::delete(&conn, inserted_comment.id).unwrap();
740     Comment::delete(&conn, inserted_comment_2.id).unwrap();
741     Post::delete(&conn, inserted_post.id).unwrap();
742     Community::delete(&conn, inserted_community.id).unwrap();
743     Person::delete(&conn, inserted_person.id).unwrap();
744     Person::delete(&conn, inserted_person_2.id).unwrap();
745
746     // Make sure its 1, not showing the blocked comment
747     assert_eq!(1, read_comment_views_with_person.len());
748
749     assert_eq!(
750       expected_comment_view_no_person,
751       read_comment_views_no_person[1]
752     );
753     assert_eq!(
754       expected_comment_view_with_person,
755       read_comment_views_with_person[0]
756     );
757
758     // Make sure block set the creator blocked
759     assert!(read_comment_from_blocked_person.creator_blocked);
760
761     assert_eq!(1, num_deleted);
762     assert_eq!(1, like_removed);
763   }
764 }