activitypub transmogrifier: accept/reject outgoing: we might send the actual object instead of the URI in some cases, handle it

This commit is contained in:
William Pitcock 2018-05-29 10:18:23 +00:00
parent 5eed1ea181
commit d96377f359

View file

@ -443,7 +443,14 @@ def prepare_outgoing(%{"type" => "Create", "object" => %{"type" => "Note"} = obj
# Mastodon Accept/Reject requires a non-normalized object containing the actor URIs,
# because of course it does.
def prepare_outgoing(%{"type" => "Accept"} = data) do
with follow_activity <- Activity.get_by_ap_id(data["object"]) do
follow_activity_id =
if is_binary(data["object"]) do
data["object"]
else
data["object"]["id"]
end
with follow_activity <- Activity.get_by_ap_id(follow_activity_id) do
object = %{
"actor" => follow_activity.actor,
"object" => follow_activity.data["object"],
@ -461,7 +468,14 @@ def prepare_outgoing(%{"type" => "Accept"} = data) do
end
def prepare_outgoing(%{"type" => "Reject"} = data) do
with follow_activity <- Activity.get_by_ap_id(data["object"]) do
follow_activity_id =
if is_binary(data["object"]) do
data["object"]
else
data["object"]["id"]
end
with follow_activity <- Activity.get_by_ap_id(follow_activity_id) do
object = %{
"actor" => follow_activity.actor,
"object" => follow_activity.data["object"],