Commit c450b248 authored by lain's avatar lain
Browse files

Merge branch 'feature/delete-follow-requests-on-user-deletion' into 'develop'

Delete outgoing pending follow requests on user deletion

See merge request !2631
parents a1aa9fa9 8d9e5868
Pipeline #26934 passed with stages
in 55 minutes and 36 seconds
......@@ -141,6 +141,12 @@ def following_query(%User{} = user) do
|> where([r], r.state == ^:follow_accept)
end
def outgoing_pending_follow_requests_query(%User{} = follower) do
__MODULE__
|> where([r], r.follower_id == ^follower.id)
|> where([r], r.state == ^:follow_pending)
end
def following(%User{} = user) do
following =
following_query(user)
......
......@@ -1489,6 +1489,8 @@ def perform(:delete, %User{} = user) do
delete_user_activities(user)
delete_outgoing_pending_follow_requests(user)
delete_or_deactivate(user)
end
......@@ -1611,6 +1613,12 @@ defp delete_activity(%{data: %{"type" => type}} = activity, user)
defp delete_activity(_activity, _user), do: "Doing nothing"
defp delete_outgoing_pending_follow_requests(user) do
user
|> FollowingRelationship.outgoing_pending_follow_requests_query()
|> Repo.delete_all()
end
def html_filter_policy(%User{no_rich_text: true}) do
Pleroma.HTML.Scrubber.TwitterText
end
......
......@@ -1159,6 +1159,9 @@ test "it deactivates a user, all follow relationships and all activities", %{use
follower = insert(:user)
{:ok, follower} = User.follow(follower, user)
locked_user = insert(:user, name: "locked", locked: true)
{:ok, _} = User.follow(user, locked_user, :follow_pending)
object = insert(:note, user: user)
activity = insert(:note_activity, user: user, note: object)
......@@ -1177,6 +1180,8 @@ test "it deactivates a user, all follow relationships and all activities", %{use
refute User.following?(follower, user)
assert %{deactivated: true} = User.get_by_id(user.id)
assert [] == User.get_follow_requests(locked_user)
user_activities =
user.ap_id
|> Activity.Queries.by_actor()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment