Merge branch 'features/incoming-create-exists' into 'develop'

transmogrifier: Drop incoming create early if it already exists

See merge request pleroma/pleroma!3026
This commit is contained in:
rinpatch 2020-09-25 12:44:33 +00:00
commit f67c967c4a
2 changed files with 7 additions and 3 deletions

View file

@ -515,15 +515,19 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
end
def handle_incoming(
%{"type" => "Create", "object" => %{"type" => objtype}} = data,
%{"type" => "Create", "object" => %{"type" => objtype, "id" => obj_id}} = data,
_options
)
when objtype in ~w{Question Answer ChatMessage Audio Video Event Article} do
data = Map.put(data, "object", strip_internal_fields(data["object"]))
with {:ok, %User{}} <- ObjectValidator.fetch_actor(data),
nil <- Activity.get_create_by_object_ap_id(obj_id),
{:ok, activity, _} <- Pipeline.common_pipeline(data, local: false) do
{:ok, activity}
else
%Activity{} = activity -> {:ok, activity}
e -> e
end
end