forked from mirrors/akkoma
add the ability to 'quarantine' an activitypub peer, causing them to be treated as an OStatus peer.
This commit is contained in:
parent
0a0c6bf394
commit
09604182d0
2 changed files with 16 additions and 1 deletions
|
@ -54,7 +54,8 @@ config :pleroma, :instance,
|
||||||
registrations_open: true,
|
registrations_open: true,
|
||||||
federating: true,
|
federating: true,
|
||||||
rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy,
|
rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy,
|
||||||
public: true
|
public: true,
|
||||||
|
quarantined_instances: []
|
||||||
|
|
||||||
config :pleroma, :activitypub, accept_blocks: true
|
config :pleroma, :activitypub, accept_blocks: true
|
||||||
|
|
||||||
|
|
|
@ -562,6 +562,17 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@quarantined_instances Keyword.get(@instance, :quarantined_instances, [])
|
||||||
|
|
||||||
|
def should_federate?(inbox, public) do
|
||||||
|
if public do
|
||||||
|
true
|
||||||
|
else
|
||||||
|
inbox_info = URI.parse(inbox)
|
||||||
|
inbox_info.host not in @quarantined_instances
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def publish(actor, activity) do
|
def publish(actor, activity) do
|
||||||
followers =
|
followers =
|
||||||
if actor.follower_address in activity.recipients do
|
if actor.follower_address in activity.recipients do
|
||||||
|
@ -571,6 +582,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
public = is_public?(activity)
|
||||||
|
|
||||||
remote_inboxes =
|
remote_inboxes =
|
||||||
(Pleroma.Web.Salmon.remote_users(activity) ++ followers)
|
(Pleroma.Web.Salmon.remote_users(activity) ++ followers)
|
||||||
|> Enum.filter(fn user -> User.ap_enabled?(user) end)
|
|> Enum.filter(fn user -> User.ap_enabled?(user) end)
|
||||||
|
@ -578,6 +591,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
(data["endpoints"] && data["endpoints"]["sharedInbox"]) || data["inbox"]
|
(data["endpoints"] && data["endpoints"]["sharedInbox"]) || data["inbox"]
|
||||||
end)
|
end)
|
||||||
|> Enum.uniq()
|
|> Enum.uniq()
|
||||||
|
|> Enum.filter(fn inbox -> should_federate?(inbox, public) end)
|
||||||
|
|
||||||
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
|
||||||
json = Jason.encode!(data)
|
json = Jason.encode!(data)
|
||||||
|
|
Loading…
Reference in a new issue