federator: move activitypub relaying to the AP publisher module
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 12 May 2019 04:00:55 +0000 (04:00 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sun, 12 May 2019 05:04:16 +0000 (05:04 +0000)
lib/pleroma/web/activity_pub/publisher.ex
lib/pleroma/web/federator/federator.ex

index ee9f0fdd304b4d7b6a7f7c7dd9bcfb1bfc882ba6..11e54b77d3472eda80f47e1ff7dea4f9d207325c 100644 (file)
@@ -4,8 +4,10 @@
 
 defmodule Pleroma.Web.ActivityPub.Publisher do
   alias Pleroma.Activity
+  alias Pleroma.Config
   alias Pleroma.Instances
   alias Pleroma.User
+  alias Pleroma.Web.ActivityPub.Relay
   alias Pleroma.Web.ActivityPub.Transmogrifier
 
   import Pleroma.Web.ActivityPub.Visibility
@@ -104,6 +106,11 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
 
     public = is_public?(activity)
 
+    if public && Config.get([:instance, :allow_relay]) do
+      Logger.info(fn -> "Relaying #{activity.data["id"]} out" end)
+      Relay.publish(activity)
+    end
+
     {:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
     json = Jason.encode!(data)
 
index ef2708c0776fb233ba6e2dca619b26d00115b700..252d3b0095175d45293c7896b320fe3af12cc43c 100644 (file)
@@ -7,7 +7,6 @@ defmodule Pleroma.Web.Federator do
   alias Pleroma.Object.Containment
   alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Web.ActivityPub.Relay
   alias Pleroma.Web.ActivityPub.Transmogrifier
   alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.ActivityPub.Visibility
@@ -100,11 +99,6 @@ defmodule Pleroma.Web.Federator do
           Logger.info(fn -> "Sending #{activity.data["id"]} out via Salmon" end)
           Pleroma.Web.Salmon.publish(actor, activity)
         end
-
-        if Keyword.get(Application.get_env(:pleroma, :instance), :allow_relay) do
-          Logger.info(fn -> "Relaying #{activity.data["id"]} out" end)
-          Relay.publish(activity)
-        end
       end
 
       Publisher.publish(actor, activity)