Federate non-public over ActivityPub only, do some better signing.

This commit is contained in:
lain 2018-02-18 16:05:25 +01:00
parent 4bc57ef20c
commit 803bdc1a67
2 changed files with 10 additions and 7 deletions

View file

@ -288,12 +288,12 @@ def publish(actor, activity) do
|> Enum.uniq |> Enum.uniq
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data) {:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
json = Poison.encode!(data)
Enum.each remote_inboxes, fn(inbox) -> Enum.each remote_inboxes, fn(inbox) ->
Logger.info("Federating #{activity.data["id"]} to #{inbox}") Logger.info("Federating #{activity.data["id"]} to #{inbox}")
host = URI.parse(inbox).host host = URI.parse(inbox).host
signature = Pleroma.Web.HTTPSignatures.sign(actor, %{host: host}) signature = Pleroma.Web.HTTPSignatures.sign(actor, %{host: host, "content-length": byte_size(json)})
@httpoison.post(inbox, Poison.encode!(data), [{"Content-Type", "application/activity+json"}, {"signature", signature}]) @httpoison.post(inbox, json, [{"Content-Type", "application/activity+json"}, {"signature", signature}])
end end
end end

View file

@ -2,6 +2,7 @@ defmodule Pleroma.Web.Federator do
use GenServer use GenServer
alias Pleroma.User alias Pleroma.User
alias Pleroma.Web.{WebFinger, Websub} alias Pleroma.Web.{WebFinger, Websub}
alias Pleroma.Web.ActivityPub.ActivityPub
require Logger require Logger
@websub Application.get_env(:pleroma, :websub) @websub Application.get_env(:pleroma, :websub)
@ -42,11 +43,13 @@ def handle(:publish, activity) do
Logger.debug(fn -> "Running publish for #{activity.data["id"]}" end) 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 with actor when not is_nil(actor) <- User.get_cached_by_ap_id(activity.data["actor"]) do
{:ok, actor} = WebFinger.ensure_keys_present(actor) {:ok, actor} = WebFinger.ensure_keys_present(actor)
Logger.debug(fn -> "Sending #{activity.data["id"]} out via salmon" end) if ActivityPub.is_public?(activity) do
Pleroma.Web.Salmon.publish(actor, activity) 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) Logger.debug(fn -> "Sending #{activity.data["id"]} out via websub" end)
Websub.publish(Pleroma.Web.OStatus.feed_path(actor), actor, activity) Websub.publish(Pleroma.Web.OStatus.feed_path(actor), actor, activity)
end
Logger.debug(fn -> "Sending #{activity.data["id"]} out via AP" end) Logger.debug(fn -> "Sending #{activity.data["id"]} out via AP" end)
Pleroma.Web.ActivityPub.ActivityPub.publish(actor, activity) Pleroma.Web.ActivityPub.ActivityPub.publish(actor, activity)