mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-22 16:16:34 +00:00
Address case where instance reachability status couldn't be updated
This commit is contained in:
parent
55cc1ba50e
commit
1b8141b506
2 changed files with 12 additions and 9 deletions
1
changelog.d/publisher-reachability.fix
Normal file
1
changelog.d/publisher-reachability.fix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Address case where instance reachability status couldn't be updated
|
|
@ -148,12 +148,17 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
||||||
{"digest", p.digest}
|
{"digest", p.digest}
|
||||||
]
|
]
|
||||||
) do
|
) do
|
||||||
maybe_set_reachable(p.unreachable_since, p.inbox)
|
if not is_nil(p.unreachable_since) do
|
||||||
|
Instances.set_reachable(p.inbox)
|
||||||
|
end
|
||||||
|
|
||||||
result
|
result
|
||||||
else
|
else
|
||||||
{_post_result, %{status: code} = response} = e ->
|
{_post_result, %{status: code} = response} = e ->
|
||||||
maybe_set_unreachable(p.unreachable_since, p.inbox)
|
if is_nil(p.unreachable_since) do
|
||||||
|
Instances.set_unreachable(p.inbox)
|
||||||
|
end
|
||||||
|
|
||||||
Logger.metadata(activity: p.activity_id, inbox: p.inbox, status: code)
|
Logger.metadata(activity: p.activity_id, inbox: p.inbox, status: code)
|
||||||
Logger.error("Publisher failed to inbox #{p.inbox} with status #{code}")
|
Logger.error("Publisher failed to inbox #{p.inbox} with status #{code}")
|
||||||
|
|
||||||
|
@ -174,7 +179,10 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
||||||
connection_pool_snooze()
|
connection_pool_snooze()
|
||||||
|
|
||||||
e ->
|
e ->
|
||||||
maybe_set_unreachable(p.unreachable_since, p.inbox)
|
if is_nil(p.unreachable_since) do
|
||||||
|
Instances.set_unreachable(p.inbox)
|
||||||
|
end
|
||||||
|
|
||||||
Logger.metadata(activity: p.activity_id, inbox: p.inbox)
|
Logger.metadata(activity: p.activity_id, inbox: p.inbox)
|
||||||
Logger.error("Publisher failed to inbox #{p.inbox} #{inspect(e)}")
|
Logger.error("Publisher failed to inbox #{p.inbox} #{inspect(e)}")
|
||||||
{:error, e}
|
{:error, e}
|
||||||
|
@ -183,12 +191,6 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
||||||
|
|
||||||
defp connection_pool_snooze, do: {:snooze, 3}
|
defp connection_pool_snooze, do: {:snooze, 3}
|
||||||
|
|
||||||
defp maybe_set_reachable(%NaiveDateTime{}, inbox), do: Instances.set_reachable(inbox)
|
|
||||||
defp maybe_set_reachable(_, _), do: :ok
|
|
||||||
|
|
||||||
defp maybe_set_unreachable(nil, inbox), do: Instances.set_unreachable(inbox)
|
|
||||||
defp maybe_set_unreachable(%NaiveDateTime{}, _), do: :ok
|
|
||||||
|
|
||||||
defp signature_host(%URI{port: port, scheme: scheme, host: host}) do
|
defp signature_host(%URI{port: port, scheme: scheme, host: host}) do
|
||||||
if port == URI.default_port(scheme) do
|
if port == URI.default_port(scheme) do
|
||||||
host
|
host
|
||||||
|
|
Loading…
Reference in a new issue