When purging a federated user, federate local community removals.

This commit is contained in:
Dessalines 2024-03-05 08:49:11 -05:00
parent 7f9950fe85
commit cec61d116b

View file

@ -1,3 +1,4 @@
use crate::ban_nonlocal_user_from_local_communities;
use activitypub_federation::config::Data;
use actix_web::web::Json;
use lemmy_api_common::{
@ -28,7 +29,7 @@ pub async fn purge_person(
// Only let admin purge an item
is_admin(&local_user_view)?;
// Read the person to get their images
// Read the local user to get their images, and delete them
if let Ok(local_user) = LocalUserView::read_person(&mut context.pool(), data.person_id).await {
let pictrs_uploads =
LocalImage::get_all_by_local_user_id(&mut context.pool(), &local_user.local_user.id).await?;
@ -40,6 +41,18 @@ pub async fn purge_person(
}
}
let person = Person::read(&mut context.pool(), data.person_id).await?;
ban_nonlocal_user_from_local_communities(
&local_user_view,
&person,
true,
&data.reason,
&Some(true),
&None,
&context,
)
.await?;
// Clear profile data.
Person::delete_account(&mut context.pool(), data.person_id).await?;
// Keep person record, but mark as banned to prevent login or refetching from home instance.