Browse Source

restore original RemoveUserContent functionality

feature/restore-post-wipe
DashEightMate 1 year ago
parent
commit
ef52863580
  1. 11
      server/lemmy_db/src/comment.rs
  2. 20
      server/lemmy_db/src/post.rs
  3. 4
      server/src/api/user.rs

11
server/lemmy_db/src/comment.rs

@ -199,6 +199,17 @@ impl Comment {
.get_result::<Self>(conn)
}
pub fn permadelete_user_comments(conn: &PgConnection, for_creator_id: i32) -> Result<Vec<i32>, Error> {
use crate::schema::comment::dsl::*;
diesel::update(
comment
.filter(creator_id.eq(for_creator_id))
)
.set((deleted.eq(true), updated.eq(naive_now()), content.eq("*Permananently Deleted*")))
.returning(id)
.get_results(conn)
}
pub fn remove_user_comments(conn: &PgConnection, for_creator_id: i32) -> Result<Vec<i32>, Error> {
use crate::schema::comment::dsl::*;
diesel::update(

20
server/lemmy_db/src/post.rs

@ -209,6 +209,26 @@ impl Post {
.get_result::<Self>(conn)
}
pub fn permadelete_user_posts(conn: &PgConnection, for_creator_id: i32) -> Result<Vec<i32>, 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((
deleted.eq(true),
updated.eq(naive_now()),
name.eq(perma_deleted),
url.eq(perma_deleted_url),
body.eq(perma_deleted)))
.returning(id)
.get_results(conn)
}
pub fn update_featured(
conn: &PgConnection,
post_id: i32,

4
server/src/api/user.rs

@ -1754,12 +1754,12 @@ impl Perform for RemoveUserContent {
// also returns us the list of ids that were updated
let banned_user_id = data.user_id;
let post_ids = blocking(context.pool(), move |conn| {
Post::remove_user_posts(conn, banned_user_id)
Post::permadelete_user_posts(conn, banned_user_id)
})
.await??;
let comment_ids = blocking(context.pool(), move |conn| {
Comment::remove_user_comments(conn, banned_user_id)
Comment::permadelete_user_comments(conn, banned_user_id)
})
.await??;

Loading…
Cancel
Save