mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-01 01:36:12 -04:00
This commit is contained in:
parent
9d4d6ce881
commit
375e232217
@ -10,7 +10,7 @@ use lemmy_db_schema::{
|
|||||||
source::{
|
source::{
|
||||||
image_upload::ImageUpload,
|
image_upload::ImageUpload,
|
||||||
moderator::{AdminPurgePerson, AdminPurgePersonForm},
|
moderator::{AdminPurgePerson, AdminPurgePersonForm},
|
||||||
person::Person,
|
person::{Person, PersonUpdateForm},
|
||||||
},
|
},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
@ -29,17 +29,29 @@ pub async fn purge_person(
|
|||||||
// Read the person to get their images
|
// Read the person to get their images
|
||||||
let person_id = data.person_id;
|
let person_id = data.person_id;
|
||||||
|
|
||||||
let local_user = LocalUserView::read_person(&mut context.pool(), person_id).await?;
|
if let Ok(local_user) = LocalUserView::read_person(&mut context.pool(), person_id).await {
|
||||||
let pictrs_uploads =
|
let pictrs_uploads =
|
||||||
ImageUpload::get_all_by_local_user_id(&mut context.pool(), &local_user.local_user.id).await?;
|
ImageUpload::get_all_by_local_user_id(&mut context.pool(), &local_user.local_user.id).await?;
|
||||||
|
|
||||||
for upload in pictrs_uploads {
|
for upload in pictrs_uploads {
|
||||||
delete_image_from_pictrs(&upload.pictrs_alias, &upload.pictrs_delete_token, &context)
|
delete_image_from_pictrs(&upload.pictrs_alias, &upload.pictrs_delete_token, &context)
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Person::delete(&mut context.pool(), person_id).await?;
|
// Clear profile data.
|
||||||
|
Person::delete_account(&mut context.pool(), person_id).await?;
|
||||||
|
// Keep person record, but mark as banned to prevent login or refetching from home instance.
|
||||||
|
Person::update(
|
||||||
|
&mut context.pool(),
|
||||||
|
person_id,
|
||||||
|
&PersonUpdateForm {
|
||||||
|
banned: Some(true),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
// Mod tables
|
// Mod tables
|
||||||
let form = AdminPurgePersonForm {
|
let form = AdminPurgePersonForm {
|
||||||
|
Loading…
Reference in New Issue
Block a user