logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: 2f14990c5c57df00126ea2b06ccb706c6dd8f918
parent 2e2caad28db9dbc7342ac706bc743ec393c2e7e4
Author: Mark Felder <feld@feld.me>
Date:   Mon, 15 Jul 2024 10:25:18 -0400

Change PurgeExpiredActivity to use the background queue

Diffstat:

Mlib/pleroma/workers/purge_expired_activity.ex8+++++---
Mtest/pleroma/workers/purge_expired_activity_test.exs4++--
2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/pleroma/workers/purge_expired_activity.ex b/lib/pleroma/workers/purge_expired_activity.ex @@ -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() diff --git a/test/pleroma/workers/purge_expired_activity_test.exs b/test/pleroma/workers/purge_expired_activity_test.exs @@ -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