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 <insomnia-void@protonmail.com>
This commit is contained in:
SleeplessOne1917 2024-02-18 14:09:46 +00:00 committed by GitHub
parent 5d551e6da5
commit 39345466da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View file

@ -17,6 +17,7 @@ use lemmy_db_schema::{
community_aggregates, community_aggregates,
community_block, community_block,
community_follower, community_follower,
community_person_ban,
instance_block, instance_block,
local_user, local_user,
}, },
@ -58,6 +59,13 @@ fn queries<'a>() -> Queries<
.and(community_block::person_id.eq(person_id_join)), .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 = ( let selection = (
@ -65,6 +73,7 @@ fn queries<'a>() -> Queries<
CommunityFollower::select_subscribed_type(), CommunityFollower::select_subscribed_type(),
community_block::community_id.nullable().is_not_null(), community_block::community_id.nullable().is_not_null(),
community_aggregates::all_columns, community_aggregates::all_columns,
community_person_ban::person_id.nullable().is_not_null(),
); );
let not_removed_or_deleted = community::removed let not_removed_or_deleted = community::removed

View file

@ -80,6 +80,7 @@ pub struct CommunityView {
pub subscribed: SubscribedType, pub subscribed: SubscribedType,
pub blocked: bool, pub blocked: bool,
pub counts: CommunityAggregates, pub counts: CommunityAggregates,
pub banned_from_community: bool,
} }
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]