diff options
author | rinpatch <rinpatch@sdf.org> | 2020-04-29 14:26:31 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-05-02 19:05:13 +0300 |
commit | e55876409b523d81bc19db876bc90f29ba80a47c (patch) | |
tree | b85e0ab309c870f2b5bbb6d3bd94b0dff3de3856 /lib/pleroma/user.ex | |
parent | e186d9941d4cf4708186681fcea60b23919c46ed (diff) | |
download | pleroma-e55876409b523d81bc19db876bc90f29ba80a47c.tar.gz |
Deactivate local users on deletion instead of deleting the record
Prevents the possibility of re-registration, which allowed to read
DMs of the deleted account.
Also includes a migration that tries to find any already deleted
accounts and insert skeletons for them.
Closes pleroma/pleroma#1687
Diffstat (limited to 'lib/pleroma/user.ex')
-rw-r--r-- | lib/pleroma/user.ex | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index b451202b2..99358ddaf 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -1445,8 +1445,15 @@ defmodule Pleroma.User do end) delete_user_activities(user) - invalidate_cache(user) - Repo.delete(user) + + if user.local do + user + |> change(%{deactivated: true, email: nil}) + |> update_and_set_cache() + else + invalidate_cache(user) + Repo.delete(user) + end end def perform(:deactivate_async, user, status), do: deactivate(user, status) |