Instance.set_reachable/1 should delete any existing ReachabilityWorker jobs for that instance

This commit is contained in:
Mark Felder 2025-06-27 18:07:46 -07:00
commit ff5f88aae3
2 changed files with 40 additions and 3 deletions

View file

@ -92,9 +92,20 @@ defmodule Pleroma.Instances.Instance do
def reachable?(url_or_host) when is_binary(url_or_host), do: true
def set_reachable(url_or_host) when is_binary(url_or_host) do
%Instance{host: host(url_or_host)}
|> changeset(%{unreachable_since: nil})
|> Repo.insert(on_conflict: {:replace, [:unreachable_since]}, conflict_target: :host)
host = host(url_or_host)
result =
%Instance{host: host}
|> changeset(%{unreachable_since: nil})
|> Repo.insert(on_conflict: {:replace, [:unreachable_since]}, conflict_target: :host)
# Delete any existing reachability testing jobs for this instance
Oban.Job
|> Ecto.Query.where(worker: "Pleroma.Workers.ReachabilityWorker")
|> Ecto.Query.where([j], j.args["domain"] == ^host)
|> Oban.delete_all_jobs()
result
end
def set_reachable(_), do: {:error, nil}