Skip to content

Commit

Permalink
Dont purge posts/comments when user deletes account (ref #2426)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic committed Nov 4, 2022
1 parent b5cd732 commit 1de7a08
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 49 deletions.
15 changes: 0 additions & 15 deletions crates/api_common/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,21 +763,6 @@ pub async fn delete_user_account(
}
// No need to update avatar and banner, those are handled in Person::delete_account

// Comments
let permadelete = move |conn: &mut _| Comment::permadelete_for_creator(conn, person_id);
blocking(pool, permadelete)
.await?
.map_err(|e| LemmyError::from_error_message(e, "couldnt_update_comment"))?;

// Posts
let permadelete = move |conn: &mut _| Post::permadelete_for_creator(conn, person_id);
blocking(pool, permadelete)
.await?
.map_err(|e| LemmyError::from_error_message(e, "couldnt_update_post"))?;

// Purge image posts
purge_image_posts_for_person(person_id, pool, settings, client).await?;

blocking(pool, move |conn| Person::delete_account(conn, person_id)).await??;

Ok(())
Expand Down
14 changes: 0 additions & 14 deletions crates/db_schema/src/impls/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,6 @@ use diesel_ltree::Ltree;
use url::Url;

impl Comment {
pub fn permadelete_for_creator(
conn: &mut PgConnection,
for_creator_id: PersonId,
) -> Result<Vec<Self>, Error> {
use crate::schema::comment::dsl::*;
diesel::update(comment.filter(creator_id.eq(for_creator_id)))
.set((
content.eq("*Permananently Deleted*"),
deleted.eq(true),
updated.eq(naive_now()),
))
.get_results::<Self>(conn)
}

pub fn update_removed_for_creator(
conn: &mut PgConnection,
for_creator_id: PersonId,
Expand Down
20 changes: 0 additions & 20 deletions crates/db_schema/src/impls/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,6 @@ impl Post {
.load::<Self>(conn)
}

pub fn permadelete_for_creator(
conn: &mut PgConnection,
for_creator_id: PersonId,
) -> Result<Vec<Self>, Error> {
use crate::schema::post::dsl::*;

let perma_deleted = "*Permananently Deleted*";
let perma_deleted_url = "https://deleted.com";

diesel::update(post.filter(creator_id.eq(for_creator_id)))
.set((
name.eq(perma_deleted),
url.eq(perma_deleted_url),
body.eq(perma_deleted),
deleted.eq(true),
updated.eq(naive_now()),
))
.get_results::<Self>(conn)
}

pub fn update_removed_for_creator(
conn: &mut PgConnection,
for_creator_id: PersonId,
Expand Down

0 comments on commit 1de7a08

Please sign in to comment.