From 99158b88d7698b6301d9175aa95f45998c803770 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 10 Aug 2021 10:15:00 -0400 Subject: [PATCH] Adding creator_blocked to PersonMentionView --- .../db_views_actor/src/person_mention_view.rs | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/db_views_actor/src/person_mention_view.rs b/crates/db_views_actor/src/person_mention_view.rs index b391345ff..45515dbf5 100644 --- a/crates/db_views_actor/src/person_mention_view.rs +++ b/crates/db_views_actor/src/person_mention_view.rs @@ -19,6 +19,7 @@ use lemmy_db_schema::{ community_person_ban, person, person_alias_1, + person_block, person_mention, post, }, @@ -26,6 +27,7 @@ use lemmy_db_schema::{ comment::{Comment, CommentSaved}, community::{Community, CommunityFollower, CommunityPersonBan, CommunitySafe}, person::{Person, PersonAlias1, PersonSafe, PersonSafeAlias1}, + person_block::PersonBlock, person_mention::PersonMention, post::Post, }, @@ -46,6 +48,7 @@ pub struct PersonMentionView { pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan pub subscribed: bool, // Left join to CommunityFollower pub saved: bool, // Left join to CommentSaved + pub creator_blocked: bool, // Left join to PersonBlock pub my_vote: Option, // Left join to CommentLike } @@ -60,6 +63,7 @@ type PersonMentionViewTuple = ( Option, Option, Option, + Option, Option, ); @@ -83,6 +87,7 @@ impl PersonMentionView { creator_banned_from_community, subscribed, saved, + creator_blocked, my_vote, ) = person_mention::table .find(person_mention_id) @@ -113,6 +118,13 @@ impl PersonMentionView { .and(comment_saved::person_id.eq(person_id_join)), ), ) + .left_join( + person_block::table.on( + comment::creator_id + .eq(person_block::recipient_id) + .and(person_block::person_id.eq(person_id_join)), + ), + ) .left_join( comment_like::table.on( comment::id @@ -131,6 +143,7 @@ impl PersonMentionView { community_person_ban::all_columns.nullable(), community_follower::all_columns.nullable(), comment_saved::all_columns.nullable(), + person_block::all_columns.nullable(), comment_like::score.nullable(), )) .first::(conn)?; @@ -146,6 +159,7 @@ impl PersonMentionView { creator_banned_from_community: creator_banned_from_community.is_some(), subscribed: subscribed.is_some(), saved: saved.is_some(), + creator_blocked: creator_blocked.is_some(), my_vote, }) } @@ -238,6 +252,13 @@ impl<'a> PersonMentionQueryBuilder<'a> { .and(comment_saved::person_id.eq(person_id_join)), ), ) + .left_join( + person_block::table.on( + comment::creator_id + .eq(person_block::recipient_id) + .and(person_block::person_id.eq(person_id_join)), + ), + ) .left_join( comment_like::table.on( comment::id @@ -256,6 +277,7 @@ impl<'a> PersonMentionQueryBuilder<'a> { community_person_ban::all_columns.nullable(), community_follower::all_columns.nullable(), comment_saved::all_columns.nullable(), + person_block::all_columns.nullable(), comment_like::score.nullable(), )) .into_boxed(); @@ -317,7 +339,8 @@ impl ViewToVec for PersonMentionView { creator_banned_from_community: a.7.is_some(), subscribed: a.8.is_some(), saved: a.9.is_some(), - my_vote: a.10, + creator_blocked: a.10.is_some(), + my_vote: a.11, }) .collect::>() }