fix: delete user follows when deleting user
This commit is contained in:
parent
f161e0b176
commit
bc57782bfe
5 changed files with 79 additions and 15 deletions
|
@ -226,6 +226,39 @@ impl DataManager {
|
|||
return Err(Error::DatabaseError(e.to_string()));
|
||||
}
|
||||
|
||||
// delete requests
|
||||
let res = execute!(
|
||||
&conn,
|
||||
"DELETE FROM requests WHERE owner = $1",
|
||||
&[&(id as i64)]
|
||||
);
|
||||
|
||||
if let Err(e) = res {
|
||||
return Err(Error::DatabaseError(e.to_string()));
|
||||
}
|
||||
|
||||
// delete warnings
|
||||
let res = execute!(
|
||||
&conn,
|
||||
"DELETE FROM user_warnings WHERE receiver = $1",
|
||||
&[&(id as i64)]
|
||||
);
|
||||
|
||||
if let Err(e) = res {
|
||||
return Err(Error::DatabaseError(e.to_string()));
|
||||
}
|
||||
|
||||
// delete blocks
|
||||
let res = execute!(
|
||||
&conn,
|
||||
"DELETE FROM userblocks WHERE initiator = $1 OR receiver = $1",
|
||||
&[&(id as i64)]
|
||||
);
|
||||
|
||||
if let Err(e) = res {
|
||||
return Err(Error::DatabaseError(e.to_string()));
|
||||
}
|
||||
|
||||
// delete reactions
|
||||
// reactions counts will remain the same :)
|
||||
let res = execute!(
|
||||
|
@ -245,6 +278,15 @@ impl DataManager {
|
|||
return Err(Error::DatabaseError(e.to_string()));
|
||||
}
|
||||
|
||||
// delete user follows... individually since it requires updating user counts
|
||||
for follow in self.get_userfollows_by_receiver_all(id).await? {
|
||||
self.delete_userfollow(follow.id, &user, true).await?;
|
||||
}
|
||||
|
||||
for follow in self.get_userfollows_by_initiator_all(id).await? {
|
||||
self.delete_userfollow(follow.id, &user, true).await?;
|
||||
}
|
||||
|
||||
// remove images
|
||||
let avatar = PathBufD::current().extend(&[
|
||||
self.0.dirs.media.as_str(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue