mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
federator: don't federate anything other than Note objects to OStatus
This commit is contained in:
parent
b4bd5e40e4
commit
e6d246882d
2 changed files with 22 additions and 4 deletions
|
@ -7,6 +7,7 @@ defmodule Pleroma.Web.Federator do
|
||||||
alias Pleroma.Web.ActivityPub.Relay
|
alias Pleroma.Web.ActivityPub.Relay
|
||||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||||
alias Pleroma.Web.ActivityPub.Utils
|
alias Pleroma.Web.ActivityPub.Utils
|
||||||
|
alias Pleroma.Web.OStatus
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@websub Application.get_env(:pleroma, :websub)
|
@websub Application.get_env(:pleroma, :websub)
|
||||||
|
@ -63,11 +64,13 @@ defmodule Pleroma.Web.Federator do
|
||||||
{:ok, actor} = WebFinger.ensure_keys_present(actor)
|
{:ok, actor} = WebFinger.ensure_keys_present(actor)
|
||||||
|
|
||||||
if ActivityPub.is_public?(activity) do
|
if ActivityPub.is_public?(activity) do
|
||||||
Logger.info(fn -> "Sending #{activity.data["id"]} out via WebSub" end)
|
if OStatus.is_representable?(activity) do
|
||||||
Websub.publish(Pleroma.Web.OStatus.feed_path(actor), actor, activity)
|
Logger.info(fn -> "Sending #{activity.data["id"]} out via WebSub" end)
|
||||||
|
Websub.publish(Pleroma.Web.OStatus.feed_path(actor), actor, activity)
|
||||||
|
|
||||||
Logger.info(fn -> "Sending #{activity.data["id"]} out via Salmon" end)
|
Logger.info(fn -> "Sending #{activity.data["id"]} out via Salmon" end)
|
||||||
Pleroma.Web.Salmon.publish(actor, activity)
|
Pleroma.Web.Salmon.publish(actor, activity)
|
||||||
|
end
|
||||||
|
|
||||||
if Keyword.get(Application.get_env(:pleroma, :instance), :allow_relay) do
|
if Keyword.get(Application.get_env(:pleroma, :instance), :allow_relay) do
|
||||||
Logger.info(fn -> "Relaying #{activity.data["id"]} out" end)
|
Logger.info(fn -> "Relaying #{activity.data["id"]} out" end)
|
||||||
|
|
|
@ -11,6 +11,21 @@ defmodule Pleroma.Web.OStatus do
|
||||||
alias Pleroma.Web.OStatus.{FollowHandler, UnfollowHandler, NoteHandler, DeleteHandler}
|
alias Pleroma.Web.OStatus.{FollowHandler, UnfollowHandler, NoteHandler, DeleteHandler}
|
||||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||||
|
|
||||||
|
def is_representable?(%Activity{data: data}) do
|
||||||
|
object = Object.normalize(data["object"])
|
||||||
|
|
||||||
|
cond do
|
||||||
|
is_nil(object) ->
|
||||||
|
false
|
||||||
|
|
||||||
|
object.data["type"] == "Note" ->
|
||||||
|
true
|
||||||
|
|
||||||
|
true ->
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def feed_path(user) do
|
def feed_path(user) do
|
||||||
"#{user.ap_id}/feed.atom"
|
"#{user.ap_id}/feed.atom"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue