From 39345466da408e5893c2bcef07f6d10d2941c5fa Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Sun, 18 Feb 2024 14:09:46 +0000 Subject: [PATCH] Make it so the signed in user can see if they're banned from a community (#4458) * Make it so the signed in user can see if they're banned from a community * Use more appropriate field name --------- Co-authored-by: SleeplessOne1917 --- crates/db_views_actor/src/community_view.rs | 9 +++++++++ crates/db_views_actor/src/structs.rs | 1 + 2 files changed, 10 insertions(+) diff --git a/crates/db_views_actor/src/community_view.rs b/crates/db_views_actor/src/community_view.rs index 828738c27..c1cb6eee1 100644 --- a/crates/db_views_actor/src/community_view.rs +++ b/crates/db_views_actor/src/community_view.rs @@ -17,6 +17,7 @@ use lemmy_db_schema::{ community_aggregates, community_block, community_follower, + community_person_ban, instance_block, local_user, }, @@ -58,6 +59,13 @@ fn queries<'a>() -> Queries< .and(community_block::person_id.eq(person_id_join)), ), ) + .left_join( + community_person_ban::table.on( + community::id + .eq(community_person_ban::community_id) + .and(community_person_ban::person_id.eq(person_id_join)), + ), + ) }; let selection = ( @@ -65,6 +73,7 @@ fn queries<'a>() -> Queries< CommunityFollower::select_subscribed_type(), community_block::community_id.nullable().is_not_null(), community_aggregates::all_columns, + community_person_ban::person_id.nullable().is_not_null(), ); let not_removed_or_deleted = community::removed diff --git a/crates/db_views_actor/src/structs.rs b/crates/db_views_actor/src/structs.rs index 46817be78..f25662f7b 100644 --- a/crates/db_views_actor/src/structs.rs +++ b/crates/db_views_actor/src/structs.rs @@ -80,6 +80,7 @@ pub struct CommunityView { pub subscribed: SubscribedType, pub blocked: bool, pub counts: CommunityAggregates, + pub banned_from_community: bool, } #[derive(Debug, Serialize, Deserialize, Clone)]