Federate non-public over ActivityPub only, do some better signing.
authorlain <lain@soykaf.club>
Sun, 18 Feb 2018 15:05:25 +0000 (16:05 +0100)
committerlain <lain@soykaf.club>
Sun, 18 Feb 2018 15:05:25 +0000 (16:05 +0100)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/federator/federator.ex

index a0b51da89eaaebaa6218b62eb1c0b06545c83324..1a795bad1aacfa91f79dba102bca5d4b321800e8 100644 (file)
@@ -288,12 +288,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     |> Enum.uniq
 
     {:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
-
+    json = Poison.encode!(data)
     Enum.each remote_inboxes, fn(inbox) ->
       Logger.info("Federating #{activity.data["id"]} to #{inbox}")
       host = URI.parse(inbox).host
-      signature = Pleroma.Web.HTTPSignatures.sign(actor, %{host: host})
-      @httpoison.post(inbox, Poison.encode!(data), [{"Content-Type", "application/activity+json"}, {"signature", signature}])
+      signature = Pleroma.Web.HTTPSignatures.sign(actor, %{host: host, "content-length": byte_size(json)})
+      @httpoison.post(inbox, json, [{"Content-Type", "application/activity+json"}, {"signature", signature}])
     end
   end
 
index 68e5544e7c2d5fdb68e46059e79fc02c7b739a66..042c202be5c294d2a125ae7ccedd490d27fbc674 100644 (file)
@@ -2,6 +2,7 @@ defmodule Pleroma.Web.Federator do
   use GenServer
   alias Pleroma.User
   alias Pleroma.Web.{WebFinger, Websub}
+  alias Pleroma.Web.ActivityPub.ActivityPub
   require Logger
 
   @websub Application.get_env(:pleroma, :websub)
@@ -42,11 +43,13 @@ defmodule Pleroma.Web.Federator do
     Logger.debug(fn -> "Running publish for #{activity.data["id"]}" end)
     with actor when not is_nil(actor) <- User.get_cached_by_ap_id(activity.data["actor"]) do
       {:ok, actor} = WebFinger.ensure_keys_present(actor)
-      Logger.debug(fn -> "Sending #{activity.data["id"]} out via salmon" end)
-      Pleroma.Web.Salmon.publish(actor, activity)
+      if ActivityPub.is_public?(activity) do
+        Logger.debug(fn -> "Sending #{activity.data["id"]} out via salmon" end)
+        Pleroma.Web.Salmon.publish(actor, activity)
 
-      Logger.debug(fn -> "Sending #{activity.data["id"]} out via websub" end)
-      Websub.publish(Pleroma.Web.OStatus.feed_path(actor), actor, activity)
+        Logger.debug(fn -> "Sending #{activity.data["id"]} out via websub" end)
+        Websub.publish(Pleroma.Web.OStatus.feed_path(actor), actor, activity)
+      end
 
       Logger.debug(fn -> "Sending #{activity.data["id"]} out via AP" end)
       Pleroma.Web.ActivityPub.ActivityPub.publish(actor, activity)