forked from AkkomaGang/akkoma
remove public post quarantine exception (#114)
Reviewed-on: AkkomaGang/akkoma#114
This commit is contained in:
parent
1f8e5be051
commit
90c4785b89
5 changed files with 40 additions and 18 deletions
|
@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- extended runtime module support, see config cheatsheet
|
- extended runtime module support, see config cheatsheet
|
||||||
- quote posting; quotes are limited to public posts
|
- quote posting; quotes are limited to public posts
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- quarantining is now considered absolutely; public activities are no longer
|
||||||
|
an exception.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Updated mastoFE path, for the newer version
|
- Updated mastoFE path, for the newer version
|
||||||
|
|
||||||
|
|
|
@ -691,7 +691,7 @@
|
||||||
key_placeholder: "instance",
|
key_placeholder: "instance",
|
||||||
value_placeholder: "reason",
|
value_placeholder: "reason",
|
||||||
description:
|
description:
|
||||||
"List of ActivityPub instances where private (DMs, followers-only) activities will not be sent and the reason for doing so",
|
"List of ActivityPub instances where activities will not be sent, and the reason for doing so",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
{"quarantined.com", "Reason"},
|
{"quarantined.com", "Reason"},
|
||||||
{"*.quarantined.com", "Reason"}
|
{"*.quarantined.com", "Reason"}
|
||||||
|
|
|
@ -34,7 +34,7 @@ To add configuration to your config file, you can copy it from the base config.
|
||||||
* `federation_reachability_timeout_days`: Timeout (in days) of each external federation target being unreachable prior to pausing federating to it.
|
* `federation_reachability_timeout_days`: Timeout (in days) of each external federation target being unreachable prior to pausing federating to it.
|
||||||
* `allow_relay`: Permits remote instances to subscribe to all public posts of your instance. This may increase the visibility of your instance.
|
* `allow_relay`: Permits remote instances to subscribe to all public posts of your instance. This may increase the visibility of your instance.
|
||||||
* `public`: Makes the client API in authenticated mode-only except for user-profiles. Useful for disabling the Local Timeline and The Whole Known Network. Note that there is a dependent setting restricting or allowing unauthenticated access to specific resources, see `restrict_unauthenticated` for more details.
|
* `public`: Makes the client API in authenticated mode-only except for user-profiles. Useful for disabling the Local Timeline and The Whole Known Network. Note that there is a dependent setting restricting or allowing unauthenticated access to specific resources, see `restrict_unauthenticated` for more details.
|
||||||
* `quarantined_instances`: ActivityPub instances where private (DMs, followers-only) activities will not be send.
|
* `quarantined_instances`: ActivityPub instances where activities will not be sent. They can still reach there via other means, we just won't send them.
|
||||||
* `allowed_post_formats`: MIME-type list of formats allowed to be posted (transformed into HTML).
|
* `allowed_post_formats`: MIME-type list of formats allowed to be posted (transformed into HTML).
|
||||||
* `extended_nickname_format`: Set to `true` to use extended local nicknames format (allows underscores/dashes). This will break federation with
|
* `extended_nickname_format`: Set to `true` to use extended local nicknames format (allows underscores/dashes). This will break federation with
|
||||||
older software for theses nicknames.
|
older software for theses nicknames.
|
||||||
|
|
|
@ -103,10 +103,7 @@ defp signature_host(%URI{port: port, scheme: scheme, host: host}) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp should_federate?(inbox, public) do
|
defp should_federate?(inbox) do
|
||||||
if public do
|
|
||||||
true
|
|
||||||
else
|
|
||||||
%{host: host} = URI.parse(inbox)
|
%{host: host} = URI.parse(inbox)
|
||||||
|
|
||||||
quarantined_instances =
|
quarantined_instances =
|
||||||
|
@ -116,7 +113,6 @@ defp should_federate?(inbox, public) do
|
||||||
|
|
||||||
!Pleroma.Web.ActivityPub.MRF.subdomain_match?(quarantined_instances, host)
|
!Pleroma.Web.ActivityPub.MRF.subdomain_match?(quarantined_instances, host)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
@spec recipients(User.t(), Activity.t()) :: list(User.t()) | []
|
@spec recipients(User.t(), Activity.t()) :: list(User.t()) | []
|
||||||
defp recipients(actor, activity) do
|
defp recipients(actor, activity) do
|
||||||
|
@ -192,7 +188,6 @@ def determine_inbox(
|
||||||
|
|
||||||
def publish(%User{} = actor, %{data: %{"bcc" => bcc}} = activity)
|
def publish(%User{} = actor, %{data: %{"bcc" => bcc}} = activity)
|
||||||
when is_list(bcc) and bcc != [] do
|
when is_list(bcc) and bcc != [] do
|
||||||
public = is_public?(activity)
|
|
||||||
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
|
||||||
|
|
||||||
recipients = recipients(actor, activity)
|
recipients = recipients(actor, activity)
|
||||||
|
@ -201,7 +196,7 @@ def publish(%User{} = actor, %{data: %{"bcc" => bcc}} = activity)
|
||||||
recipients
|
recipients
|
||||||
|> Enum.filter(&User.ap_enabled?/1)
|
|> Enum.filter(&User.ap_enabled?/1)
|
||||||
|> Enum.map(fn actor -> actor.inbox end)
|
|> Enum.map(fn actor -> actor.inbox end)
|
||||||
|> Enum.filter(fn inbox -> should_federate?(inbox, public) end)
|
|> Enum.filter(fn inbox -> should_federate?(inbox) end)
|
||||||
|> Instances.filter_reachable()
|
|> Instances.filter_reachable()
|
||||||
|
|
||||||
Repo.checkout(fn ->
|
Repo.checkout(fn ->
|
||||||
|
@ -246,7 +241,7 @@ def publish(%User{} = actor, %Activity{} = activity) do
|
||||||
determine_inbox(activity, user)
|
determine_inbox(activity, user)
|
||||||
end)
|
end)
|
||||||
|> Enum.uniq()
|
|> Enum.uniq()
|
||||||
|> Enum.filter(fn inbox -> should_federate?(inbox, public) end)
|
|> Enum.filter(fn inbox -> should_federate?(inbox) end)
|
||||||
|> Instances.filter_reachable()
|
|> Instances.filter_reachable()
|
||||||
|> Enum.each(fn {inbox, unreachable_since} ->
|
|> Enum.each(fn {inbox, unreachable_since} ->
|
||||||
Pleroma.Web.Federator.Publisher.enqueue_one(
|
Pleroma.Web.Federator.Publisher.enqueue_one(
|
||||||
|
|
|
@ -23,7 +23,10 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
setup_all do: clear_config([:instance, :federating], true)
|
setup_all do
|
||||||
|
clear_config([:instance, :federating], true)
|
||||||
|
clear_config([:instance, :quarantined_instances], [])
|
||||||
|
end
|
||||||
|
|
||||||
describe "gather_webfinger_links/1" do
|
describe "gather_webfinger_links/1" do
|
||||||
test "it returns links" do
|
test "it returns links" do
|
||||||
|
@ -267,7 +270,7 @@ test "publish to url with with different ports" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "publish/2" do
|
describe "publish/2" do
|
||||||
test_with_mock "doesn't publish a non-public activity to quarantined instances.",
|
test_with_mock "doesn't publish any activity to quarantined instances.",
|
||||||
Pleroma.Web.Federator.Publisher,
|
Pleroma.Web.Federator.Publisher,
|
||||||
[:passthrough],
|
[:passthrough],
|
||||||
[] do
|
[] do
|
||||||
|
@ -291,10 +294,18 @@ test "publish to url with with different ports" do
|
||||||
recipients: [follower.ap_id]
|
recipients: [follower.ap_id]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
public_note_activity =
|
||||||
|
insert(:note_activity,
|
||||||
|
user: actor,
|
||||||
|
recipients: [follower.ap_id, @as_public]
|
||||||
|
)
|
||||||
|
|
||||||
res = Publisher.publish(actor, note_activity)
|
res = Publisher.publish(actor, note_activity)
|
||||||
|
|
||||||
assert res == :ok
|
assert res == :ok
|
||||||
|
|
||||||
|
:ok = Publisher.publish(actor, public_note_activity)
|
||||||
|
|
||||||
assert not called(
|
assert not called(
|
||||||
Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{
|
Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{
|
||||||
inbox: "https://domain.com/users/nick1/inbox",
|
inbox: "https://domain.com/users/nick1/inbox",
|
||||||
|
@ -302,6 +313,14 @@ test "publish to url with with different ports" do
|
||||||
id: note_activity.data["id"]
|
id: note_activity.data["id"]
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assert not called(
|
||||||
|
Pleroma.Web.Federator.Publisher.enqueue_one(Publisher, %{
|
||||||
|
inbox: "https://domain.com/users/nick1/inbox",
|
||||||
|
actor_id: actor.id,
|
||||||
|
id: public_note_activity.data["id"]
|
||||||
|
})
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
test_with_mock "Publishes a non-public activity to non-quarantined instances.",
|
test_with_mock "Publishes a non-public activity to non-quarantined instances.",
|
||||||
|
@ -345,6 +364,8 @@ test "publish to url with with different ports" do
|
||||||
Pleroma.Web.Federator.Publisher,
|
Pleroma.Web.Federator.Publisher,
|
||||||
[:passthrough],
|
[:passthrough],
|
||||||
[] do
|
[] do
|
||||||
|
Config.put([:instance, :quarantined_instances], [])
|
||||||
|
|
||||||
follower =
|
follower =
|
||||||
insert(:user, %{
|
insert(:user, %{
|
||||||
local: false,
|
local: false,
|
||||||
|
@ -379,6 +400,8 @@ test "publish to url with with different ports" do
|
||||||
Pleroma.Web.Federator.Publisher,
|
Pleroma.Web.Federator.Publisher,
|
||||||
[:passthrough],
|
[:passthrough],
|
||||||
[] do
|
[] do
|
||||||
|
clear_config([:instance, :quarantined_instances], [])
|
||||||
|
|
||||||
fetcher =
|
fetcher =
|
||||||
insert(:user,
|
insert(:user,
|
||||||
local: false,
|
local: false,
|
||||||
|
|
Loading…
Reference in a new issue