mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-13 03:01:12 +00:00
activitypub: use Activity.normalize() in several places instead of using Activity.get_by_ap_id() directly.
This commit is contained in:
parent
6f4ca7ddf7
commit
7c63e70de1
|
@ -30,7 +30,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert(map, local \\ true) when is_map(map) do
|
def insert(map, local \\ true) when is_map(map) do
|
||||||
with nil <- Activity.get_by_ap_id(map["id"]),
|
with nil <- Activity.normalize(map),
|
||||||
map <- lazy_put_activity_defaults(map),
|
map <- lazy_put_activity_defaults(map),
|
||||||
:ok <- check_actor_is_active(map["actor"]),
|
:ok <- check_actor_is_active(map["actor"]),
|
||||||
{:ok, map} <- MRF.filter(map),
|
{:ok, map} <- MRF.filter(map),
|
||||||
|
|
|
@ -460,14 +460,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
# Mastodon Accept/Reject requires a non-normalized object containing the actor URIs,
|
# Mastodon Accept/Reject requires a non-normalized object containing the actor URIs,
|
||||||
# because of course it does.
|
# because of course it does.
|
||||||
def prepare_outgoing(%{"type" => "Accept"} = data) do
|
def prepare_outgoing(%{"type" => "Accept"} = data) do
|
||||||
follow_activity_id =
|
with follow_activity <- Activity.normalize(data["object"]) do
|
||||||
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 = %{
|
object = %{
|
||||||
"actor" => follow_activity.actor,
|
"actor" => follow_activity.actor,
|
||||||
"object" => follow_activity.data["object"],
|
"object" => follow_activity.data["object"],
|
||||||
|
@ -485,14 +478,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_outgoing(%{"type" => "Reject"} = data) do
|
def prepare_outgoing(%{"type" => "Reject"} = data) do
|
||||||
follow_activity_id =
|
with follow_activity <- Activity.normalize(data["object"]) do
|
||||||
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 = %{
|
object = %{
|
||||||
"actor" => follow_activity.actor,
|
"actor" => follow_activity.actor,
|
||||||
"object" => follow_activity.data["object"],
|
"object" => follow_activity.data["object"],
|
||||||
|
|
Loading…
Reference in a new issue