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