relay: only relay create activities
authorWilliam Pitcock <nenolod@dereferenced.org>
Mon, 6 Aug 2018 08:03:10 +0000 (08:03 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 6 Aug 2018 08:22:16 +0000 (08:22 +0000)
lib/pleroma/web/activity_pub/relay.ex

index f5cf8b7f53558172146382c31be0aaf01ec772ce..d30853d62ef258d448492022460c051cad51578b 100644 (file)
@@ -1,5 +1,5 @@
 defmodule Pleroma.Web.ActivityPub.Relay do
-  alias Pleroma.{User, Object}
+  alias Pleroma.{User, Object, Activity}
   alias Pleroma.Web.ActivityPub.ActivityPub
   require Logger
 
@@ -31,7 +31,7 @@ defmodule Pleroma.Web.ActivityPub.Relay do
     :ok
   end
 
-  def publish(activity) do
+  def publish(%Activity{data: %{"type" => "Create"}} = activity) do
     with %User{} = user <- get_actor(),
          %Object{} = object <- Object.normalize(activity.data["object"]["id"]) do
       ActivityPub.announce(user, object)
@@ -39,4 +39,6 @@ defmodule Pleroma.Web.ActivityPub.Relay do
       e -> Logger.error("error: #{inspect(e)}")
     end
   end
+
+  def publish(_), do: nil
 end