X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Fworkers%2Fworker_helper.ex;h=4c0a55774d6df3364b56ac2a639d3a6ac413060a;hb=7f4d218cffaafd97d9a5fe636a1acef7ca1053d8;hp=d1f90c35beb13d36d1a6684556249cddeb4c056a;hpb=3c2c32b460c2d942d085725d14e77a96c4a01e4c;p=akkoma
diff --git a/lib/pleroma/workers/worker_helper.ex b/lib/pleroma/workers/worker_helper.ex
index d1f90c35b..4c0a55774 100644
--- a/lib/pleroma/workers/worker_helper.ex
+++ b/lib/pleroma/workers/worker_helper.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.WorkerHelper do
@@ -32,6 +32,8 @@ defmodule Pleroma.Workers.WorkerHelper do
queue: unquote(queue),
max_attempts: 1
+ alias Oban.Job
+
def enqueue(op, params, worker_args \\ []) do
params = Map.merge(%{"op" => op}, params)
queue_atom = String.to_atom(unquote(queue))
@@ -39,7 +41,13 @@ defmodule Pleroma.Workers.WorkerHelper do
unquote(caller_module)
|> apply(:new, [params, worker_args])
- |> Pleroma.Repo.insert()
+ |> Oban.insert()
+ end
+
+ @impl Oban.Worker
+ def timeout(_job) do
+ queue_atom = String.to_atom(unquote(queue))
+ Config.get([:workers, :timeout, queue_atom], :timer.minutes(1))
end
end
end