newtypes::{CommunityId, DbUrl, LocalUserId, PersonId, PostId},
source::{
comment::{Comment, CommentUpdateForm},
- community::{Community, CommunityUpdateForm},
+ community::{Community, CommunityModerator, CommunityUpdateForm},
email_verification::{EmailVerification, EmailVerificationForm},
instance::Instance,
local_site::{LocalSite, RegistrationMode},
// Purge image posts
purge_image_posts_for_person(person_id, pool, settings, client).await?;
+ // Leave communities they mod
+ CommunityModerator::leave_all_communities(pool, person_id).await?;
+
Person::delete_account(pool, person_id).await?;
Ok(())
.await
}
+ pub async fn leave_all_communities(
+ pool: &DbPool,
+ for_person_id: PersonId,
+ ) -> Result<usize, Error> {
+ use crate::schema::community_moderator::dsl::{community_moderator, person_id};
+ let conn = &mut get_conn(pool).await?;
+ diesel::delete(community_moderator.filter(person_id.eq(for_person_id)))
+ .execute(conn)
+ .await
+ }
+
pub async fn get_person_moderated_communities(
pool: &DbPool,
for_person_id: PersonId,