Change PurgeExpiredActivity to use the background queue
This commit is contained in:
parent
2e2caad28d
commit
2f14990c5c
@ -6,8 +6,8 @@ defmodule Pleroma.Workers.PurgeExpiredActivity do
|
||||
@moduledoc """
|
||||
Worker which purges expired activity.
|
||||
"""
|
||||
|
||||
use Oban.Worker, queue: :slow, max_attempts: 1, unique: [period: :infinity]
|
||||
@queue :background
|
||||
use Oban.Worker, queue: @queue, max_attempts: 1, unique: [period: :infinity]
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
@ -57,9 +57,11 @@ defmodule Pleroma.Workers.PurgeExpiredActivity do
|
||||
end
|
||||
|
||||
def get_expiration(id) do
|
||||
queue = Atom.to_string(@queue)
|
||||
|
||||
from(j in Oban.Job,
|
||||
where: j.state == "scheduled",
|
||||
where: j.queue == "slow",
|
||||
where: j.queue == ^queue,
|
||||
where: fragment("?->>'activity_id' = ?", j.args, ^id)
|
||||
)
|
||||
|> Pleroma.Repo.one()
|
||||
|
@ -42,7 +42,7 @@ defmodule Pleroma.Workers.PurgeExpiredActivityTest do
|
||||
user = Pleroma.User.get_by_ap_id(activity.actor)
|
||||
Pleroma.Repo.delete(user)
|
||||
|
||||
assert {:error, :user_not_found} =
|
||||
assert {:cancel, :user_not_found} =
|
||||
perform_job(Pleroma.Workers.PurgeExpiredActivity, %{activity_id: activity.id})
|
||||
end
|
||||
|
||||
@ -53,7 +53,7 @@ defmodule Pleroma.Workers.PurgeExpiredActivityTest do
|
||||
expires_at: DateTime.add(DateTime.utc_now(), 3601)
|
||||
})
|
||||
|
||||
assert {:error, :activity_not_found} =
|
||||
assert {:cancel, :activity_not_found} =
|
||||
perform_job(Pleroma.Workers.PurgeExpiredActivity, %{activity_id: "some_if"})
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user