mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-19 11:45:01 +00:00
user: when processing a block in User.block(), ensure all follow relationships are broken
this is needed for activitypub conformance ref #213
This commit is contained in:
parent
25946f772d
commit
320ca7b11e
1 changed files with 18 additions and 5 deletions
|
@ -505,12 +505,25 @@ defmodule Pleroma.User do
|
||||||
Repo.all(q)
|
Repo.all(q)
|
||||||
end
|
end
|
||||||
|
|
||||||
def block(user, %{ap_id: ap_id}) do
|
def block(blocker, %User{ap_id: ap_id} = blocked) do
|
||||||
blocks = user.info["blocks"] || []
|
# sever any follow relationships to prevent leaks per activitypub (Pleroma issue #213)
|
||||||
new_blocks = Enum.uniq([ap_id | blocks])
|
blocker =
|
||||||
new_info = Map.put(user.info, "blocks", new_blocks)
|
if following?(blocker, blocked) do
|
||||||
|
{:ok, blocker, _} = unfollow(blocker, blocked)
|
||||||
|
blocker
|
||||||
|
else
|
||||||
|
blocker
|
||||||
|
end
|
||||||
|
|
||||||
cs = User.info_changeset(user, %{info: new_info})
|
if following?(blocked, blocker) do
|
||||||
|
unfollow(blocked, blocker)
|
||||||
|
end
|
||||||
|
|
||||||
|
blocks = blocker.info["blocks"] || []
|
||||||
|
new_blocks = Enum.uniq([ap_id | blocks])
|
||||||
|
new_info = Map.put(blocker.info, "blocks", new_blocks)
|
||||||
|
|
||||||
|
cs = User.info_changeset(blocker, %{info: new_info})
|
||||||
update_and_set_cache(cs)
|
update_and_set_cache(cs)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue