diff options
author | lain <lain@soykaf.club> | 2018-02-19 17:37:45 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2018-02-19 17:37:45 +0100 |
commit | 297a2c7d3f2f4e79d05ed799e7bb20ed27b35a9c (patch) | |
tree | 5361d252e32d8f1f0533e74b6bc1920733e450b7 /lib | |
parent | ffa2f57c36af7f8a2f5a09fef219376eb18888ef (diff) | |
download | pleroma-297a2c7d3f2f4e79d05ed799e7bb20ed27b35a9c.tar.gz pleroma-297a2c7d3f2f4e79d05ed799e7bb20ed27b35a9c.zip |
Ignore duplicate create activities.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub_controller.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/transmogrifier.ex | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index 1a6d7ec7a..835e8bd9d 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -25,7 +25,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do # TODO: Ensure that this inbox is a recipient of the message def inbox(%{assigns: %{valid_signature: true}} = conn, params) do # File.write("/tmp/incoming.json", Poison.encode!(params)) - Logger.info(Poison.encode!(params, [pretty: 2])) + # Logger.info(Poison.encode!(params, [pretty: 2])) with {:ok, _user} <- ap_enabled_actor(params["actor"]), nil <- Activity.get_by_ap_id(params["id"]), {:ok, activity} <- Transmogrifier.handle_incoming(params) do diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 075250aa5..e53957fbf 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -37,7 +37,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do # - tags # - emoji def handle_incoming(%{"type" => "Create", "object" => %{"type" => "Note"} = object} = data) do - with %User{} = user <- User.get_or_fetch_by_ap_id(data["actor"]) do + with nil <- Activity.get_create_activity_by_object_ap_id(object["id"]), + %User{} = user <- User.get_or_fetch_by_ap_id(data["actor"]) do object = fix_object(data["object"]) params = %{ to: data["to"], @@ -54,6 +55,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do ActivityPub.create(params) else + %Activity{} = activity -> {:ok, activity} _e -> :error end end |