forked from AkkomaGang/akkoma
Add undo block handler
This commit is contained in:
parent
c8a16f334d
commit
2573332214
1 changed files with 20 additions and 3 deletions
|
@ -247,10 +247,10 @@ def handle_incoming(
|
||||||
"object" => %{"type" => "Follow", "object" => followed},
|
"object" => %{"type" => "Follow", "object" => followed},
|
||||||
"actor" => follower,
|
"actor" => follower,
|
||||||
"id" => id
|
"id" => id
|
||||||
} = data
|
} = _data
|
||||||
) do
|
) do
|
||||||
with %User{local: true} = followed = User.get_cached_by_ap_id(followed),
|
with %User{local: true} = followed <- User.get_cached_by_ap_id(followed),
|
||||||
%User{} = follower = User.get_or_fetch_by_ap_id(follower),
|
%User{} = follower <- User.get_or_fetch_by_ap_id(follower),
|
||||||
{:ok, activity} <- ActivityPub.unfollow(follower, followed, id, false) do
|
{:ok, activity} <- ActivityPub.unfollow(follower, followed, id, false) do
|
||||||
User.unfollow(follower, followed)
|
User.unfollow(follower, followed)
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
|
@ -259,6 +259,23 @@ def handle_incoming(
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def handle_incoming(
|
||||||
|
%{
|
||||||
|
"type" => "Undo",
|
||||||
|
"object" => %{"type" => "Block", "object" => blocked},
|
||||||
|
"actor" => blocker,
|
||||||
|
"id" => id
|
||||||
|
} = _data
|
||||||
|
) do
|
||||||
|
with %User{local: true} = blocked <- User.get_cached_by_ap_id(blocked),
|
||||||
|
%User{} = blocker <- User.get_or_fetch_by_ap_id(blocker),
|
||||||
|
{:ok, activity} <- ActivityPub.unblock(blocker, blocked, id, false) do
|
||||||
|
{:ok, activity}
|
||||||
|
else
|
||||||
|
e -> :error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def handle_incoming(
|
def handle_incoming(
|
||||||
%{"type" => "Block", "object" => blocked, "actor" => blocker, "id" => id} = data
|
%{"type" => "Block", "object" => blocked, "actor" => blocker, "id" => id} = data
|
||||||
) do
|
) do
|
||||||
|
|
Loading…
Reference in a new issue