Instance.set_reachable/1 should delete any existing ReachabilityWorker jobs for that instance
This commit is contained in:
parent
13db730659
commit
ff5f88aae3
2 changed files with 40 additions and 3 deletions
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue