Move local check into function.

content_removal_remote_users
Dessalines 2024-02-29 09:29:14 -05:00
parent 052860e62a
commit 469eaa2d5e
2 changed files with 71 additions and 70 deletions

View File

@ -174,6 +174,8 @@ pub(crate) async fn ban_nonlocal_user_from_local_communities(
expires: &Option<i64>, expires: &Option<i64>,
context: &Data<LemmyContext>, context: &Data<LemmyContext>,
) -> LemmyResult<()> { ) -> LemmyResult<()> {
// Only run this code for federated users
if !target.local {
let ids = Person::list_local_community_ids(&mut context.pool(), target.id).await?; let ids = Person::list_local_community_ids(&mut context.pool(), target.id).await?;
for community_id in ids { for community_id in ids {
@ -243,6 +245,7 @@ pub(crate) async fn ban_nonlocal_user_from_local_communities(
) )
.await?; .await?;
} }
}
Ok(()) Ok(())
} }

View File

@ -72,7 +72,6 @@ pub async fn ban_from_site(
let person_view = PersonView::read(&mut context.pool(), person.id).await?; let person_view = PersonView::read(&mut context.pool(), person.id).await?;
if !person.local {
ban_nonlocal_user_from_local_communities( ban_nonlocal_user_from_local_communities(
&local_user_view, &local_user_view,
&person, &person,
@ -83,7 +82,6 @@ pub async fn ban_from_site(
&context, &context,
) )
.await?; .await?;
}
ActivityChannel::submit_activity( ActivityChannel::submit_activity(
SendActivityData::BanFromSite { SendActivityData::BanFromSite {