mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2025-01-03 13:58:41 +00:00
Merge branch 'fix-3241' into 'develop'
Consider a case when users.inbox is nil (Fix 3241) Closes #3241 See merge request pleroma/pleroma!4083
This commit is contained in:
commit
56e456fb5b
3 changed files with 23 additions and 11 deletions
1
changelog.d/issue-3241.fix
Normal file
1
changelog.d/issue-3241.fix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Handle cases when users.inbox is nil.
|
|
@ -158,19 +158,18 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp should_federate?(inbox, public) do
|
def should_federate?(nil, _), do: false
|
||||||
if public do
|
def should_federate?(_, true), do: true
|
||||||
true
|
|
||||||
else
|
|
||||||
%{host: host} = URI.parse(inbox)
|
|
||||||
|
|
||||||
quarantined_instances =
|
def should_federate?(inbox, _) do
|
||||||
Config.get([:instance, :quarantined_instances], [])
|
%{host: host} = URI.parse(inbox)
|
||||||
|> Pleroma.Web.ActivityPub.MRF.instance_list_from_tuples()
|
|
||||||
|> Pleroma.Web.ActivityPub.MRF.subdomains_regex()
|
|
||||||
|
|
||||||
!Pleroma.Web.ActivityPub.MRF.subdomain_match?(quarantined_instances, host)
|
quarantined_instances =
|
||||||
end
|
Config.get([:instance, :quarantined_instances], [])
|
||||||
|
|> Pleroma.Web.ActivityPub.MRF.instance_list_from_tuples()
|
||||||
|
|> Pleroma.Web.ActivityPub.MRF.subdomains_regex()
|
||||||
|
|
||||||
|
!Pleroma.Web.ActivityPub.MRF.subdomain_match?(quarantined_instances, host)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec recipients(User.t(), Activity.t()) :: [[User.t()]]
|
@spec recipients(User.t(), Activity.t()) :: [[User.t()]]
|
||||||
|
|
|
@ -25,6 +25,17 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
||||||
|
|
||||||
setup_all do: clear_config([:instance, :federating], true)
|
setup_all do: clear_config([:instance, :federating], true)
|
||||||
|
|
||||||
|
describe "should_federate?/1" do
|
||||||
|
test "it returns false when the inbox is nil" do
|
||||||
|
refute Publisher.should_federate?(nil, false)
|
||||||
|
refute Publisher.should_federate?(nil, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "it returns true when public is true" do
|
||||||
|
assert Publisher.should_federate?(false, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "gather_webfinger_links/1" do
|
describe "gather_webfinger_links/1" do
|
||||||
test "it returns links" do
|
test "it returns links" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
@ -205,6 +216,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
||||||
refute called(Instances.set_reachable(inbox))
|
refute called(Instances.set_reachable(inbox))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@tag capture_log: true
|
||||||
test_with_mock "calls `Instances.set_unreachable` on target inbox on non-2xx HTTP response code",
|
test_with_mock "calls `Instances.set_unreachable` on target inbox on non-2xx HTTP response code",
|
||||||
Instances,
|
Instances,
|
||||||
[:passthrough],
|
[:passthrough],
|
||||||
|
|
Loading…
Reference in a new issue