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