From 1c40a631e809ed7ab7bdd0ef46ff97a124b858e8 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 6 Aug 2018 07:43:37 +0000 Subject: [PATCH] federator: actually relay the public activities --- lib/pleroma/web/activity_pub/relay.ex | 11 ++++++++++- lib/pleroma/web/federator/federator.ex | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/relay.ex b/lib/pleroma/web/activity_pub/relay.ex index 29ece7f1b..f5cf8b7f5 100644 --- a/lib/pleroma/web/activity_pub/relay.ex +++ b/lib/pleroma/web/activity_pub/relay.ex @@ -1,5 +1,5 @@ defmodule Pleroma.Web.ActivityPub.Relay do - alias Pleroma.User + alias Pleroma.{User, Object} alias Pleroma.Web.ActivityPub.ActivityPub require Logger @@ -30,4 +30,13 @@ def unfollow(target_instance) do :ok end + + def publish(activity) do + with %User{} = user <- get_actor(), + %Object{} = object <- Object.normalize(activity.data["object"]["id"]) do + ActivityPub.announce(user, object) + else + e -> Logger.error("error: #{inspect(e)}") + end + end end diff --git a/lib/pleroma/web/federator/federator.ex b/lib/pleroma/web/federator/federator.ex index ccefb0bdf..94e3979be 100644 --- a/lib/pleroma/web/federator/federator.ex +++ b/lib/pleroma/web/federator/federator.ex @@ -4,6 +4,7 @@ defmodule Pleroma.Web.Federator do alias Pleroma.Activity alias Pleroma.Web.{WebFinger, Websub} alias Pleroma.Web.ActivityPub.ActivityPub + alias Pleroma.Web.ActivityPub.Relay alias Pleroma.Web.ActivityPub.Transmogrifier alias Pleroma.Web.ActivityPub.Utils require Logger @@ -69,6 +70,9 @@ def handle(:publish, activity) do Logger.info(fn -> "Sending #{activity.data["id"]} out via Salmon" end) Pleroma.Web.Salmon.publish(actor, activity) + + Logger.info(fn -> "Relaying #{activity.data["id"]} out" end) + Pleroma.Web.ActivityPub.Relay.publish(activity) end Logger.info(fn -> "Sending #{activity.data["id"]} out via AP" end)