Change PurgeExpiredActivity to use the background queue

This commit is contained in:
Mark Felder 2024-07-15 10:25:18 -04:00
parent 2e2caad28d
commit 2f14990c5c
2 changed files with 7 additions and 5 deletions

View File

@ -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()

View File

@ -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