scheduled_jobs =
with digest_config <- Application.get_env(:pleroma, :email_notifications)[:digest],
true <- digest_config[:active] do
- [{digest_config[:schedule], {Pleroma.DigestEmailWorker, :perform, []}}]
+ [{digest_config[:schedule], {Pleroma.Daemons.DigestEmailDaemon, :perform, []}}]
else
_ -> []
end
Pleroma.Emoji,
Pleroma.Captcha,
Pleroma.FlakeId,
- Pleroma.ScheduledActivityWorker,
- Pleroma.ActivityExpirationWorker
+ Pleroma.Daemons.ScheduledActivityDaemon,
+ Pleroma.Daemons.ActivityExpirationDaemon
] ++
cachex_children() ++
hackney_pool_children() ++
# Copyright © 2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.ActivityExpirationWorker do
+defmodule Pleroma.Daemons.ActivityExpirationDaemon do
alias Pleroma.Activity
alias Pleroma.ActivityExpiration
alias Pleroma.Config
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.DigestEmailWorker do
+defmodule Pleroma.Daemons.DigestEmailDaemon do
alias Pleroma.Repo
alias Pleroma.Workers.DigestEmailsWorker
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.ScheduledActivityWorker do
+defmodule Pleroma.Daemons.ScheduledActivityDaemon do
@moduledoc """
Sends scheduled activities to the job queue.
"""
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.ActivityExpirationWorker do
- # Note: `max_attempts` is intended to be overridden in `new/2` call
- use Oban.Worker,
- queue: "activity_expiration",
- max_attempts: 1
-
use Pleroma.Workers.WorkerHelper, queue: "activity_expiration"
@impl Oban.Worker
},
_job
) do
- Pleroma.ActivityExpirationWorker.perform(:execute, activity_expiration_id)
+ Pleroma.Daemons.ActivityExpirationDaemon.perform(:execute, activity_expiration_id)
end
end
alias Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy
alias Pleroma.Web.OAuth.Token.CleanWorker
- # Note: `max_attempts` is intended to be overridden in `new/2` call
- use Oban.Worker,
- queue: "background",
- max_attempts: 1
-
use Pleroma.Workers.WorkerHelper, queue: "background"
@impl Oban.Worker
defmodule Pleroma.Workers.DigestEmailsWorker do
alias Pleroma.User
- # Note: `max_attempts` is intended to be overridden in `new/2` call
- use Oban.Worker,
- queue: "digest_emails",
- max_attempts: 1
-
use Pleroma.Workers.WorkerHelper, queue: "digest_emails"
@impl Oban.Worker
def perform(%{"op" => "digest_email", "user_id" => user_id}, _job) do
user_id
|> User.get_cached_by_id()
- |> Pleroma.DigestEmailWorker.perform()
+ |> Pleroma.Daemons.DigestEmailDaemon.perform()
end
end
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.MailerWorker do
- # Note: `max_attempts` is intended to be overridden in `new/2` call
- use Oban.Worker,
- queue: "mailer",
- max_attempts: 1
-
use Pleroma.Workers.WorkerHelper, queue: "mailer"
@impl Oban.Worker
alias Pleroma.Activity
alias Pleroma.Web.Federator
- # Note: `max_attempts` is intended to be overridden in `new/2` call
- use Oban.Worker,
- queue: "federator_outgoing",
- max_attempts: 1
-
use Pleroma.Workers.WorkerHelper, queue: "federator_outgoing"
def backoff(attempt) when is_integer(attempt) do
defmodule Pleroma.Workers.ReceiverWorker do
alias Pleroma.Web.Federator
- # Note: `max_attempts` is intended to be overridden in `new/2` call
- use Oban.Worker,
- queue: "federator_incoming",
- max_attempts: 1
-
use Pleroma.Workers.WorkerHelper, queue: "federator_incoming"
@impl Oban.Worker
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.ScheduledActivityWorker do
- # Note: `max_attempts` is intended to be overridden in `new/2` call
- use Oban.Worker,
- queue: "scheduled_activities",
- max_attempts: 1
-
use Pleroma.Workers.WorkerHelper, queue: "scheduled_activities"
@impl Oban.Worker
def perform(%{"op" => "execute", "activity_id" => activity_id}, _job) do
- Pleroma.ScheduledActivityWorker.perform(:execute, activity_id)
+ Pleroma.Daemons.ScheduledActivityDaemon.perform(:execute, activity_id)
end
end
alias Pleroma.Web.Federator
alias Pleroma.Web.Websub
- # Note: `max_attempts` is intended to be overridden in `new/2` call
- use Oban.Worker,
- queue: "federator_outgoing",
- max_attempts: 1
-
use Pleroma.Workers.WorkerHelper, queue: "federator_outgoing"
@impl Oban.Worker
defmodule Pleroma.Workers.TransmogrifierWorker do
alias Pleroma.User
- # Note: `max_attempts` is intended to be overridden in `new/2` call
- use Oban.Worker,
- queue: "transmogrifier",
- max_attempts: 1
-
use Pleroma.Workers.WorkerHelper, queue: "transmogrifier"
@impl Oban.Worker
alias Pleroma.Notification
alias Pleroma.Repo
- # Note: `max_attempts` is intended to be overridden in `new/2` call
- use Oban.Worker,
- queue: "web_push",
- max_attempts: 1
-
use Pleroma.Workers.WorkerHelper, queue: "web_push"
@impl Oban.Worker
queue = Keyword.fetch!(opts, :queue)
quote do
+ # Note: `max_attempts` is intended to be overridden in `new/2` call
+ use Oban.Worker,
+ queue: unquote(queue),
+ max_attempts: 1
+
def enqueue(op, params, worker_args \\ []) do
params = Map.merge(%{"op" => op}, params)
queue_atom = String.to_atom(unquote(queue))
test "deletes an activity" do
activity = insert(:note_activity)
expiration = insert(:expiration_in_the_past, %{activity_id: activity.id})
- Pleroma.ActivityExpirationWorker.perform(:execute, expiration.id)
+ Pleroma.Daemons.ActivityExpirationDaemon.perform(:execute, expiration.id)
refute Repo.get(Activity, activity.id)
end
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.DigestEmailWorkerTest do
+defmodule Pleroma.DigestEmailDaemonTest do
use Pleroma.DataCase
import Pleroma.Factory
- alias Pleroma.DigestEmailWorker
+ alias Pleroma.Daemons.DigestEmailDaemon
alias Pleroma.Tests.ObanHelpers
alias Pleroma.User
alias Pleroma.Web.CommonAPI
User.switch_email_notifications(user2, "digest", true)
CommonAPI.post(user, %{"status" => "hey @#{user2.nickname}!"})
- DigestEmailWorker.perform()
+ DigestEmailDaemon.perform()
ObanHelpers.perform_all()
# Performing job(s) enqueued at previous step
ObanHelpers.perform_all()
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.ScheduledActivityWorkerTest do
+defmodule Pleroma.ScheduledActivityDaemonTest do
use Pleroma.DataCase
alias Pleroma.ScheduledActivity
import Pleroma.Factory
test "creates a status from the scheduled activity" do
user = insert(:user)
scheduled_activity = insert(:scheduled_activity, user: user, params: %{status: "hi"})
- Pleroma.ScheduledActivityWorker.perform(:execute, scheduled_activity.id)
+ Pleroma.Daemons.ScheduledActivityDaemon.perform(:execute, scheduled_activity.id)
refute Repo.get(ScheduledActivity, scheduled_activity.id)
activity = Repo.all(Pleroma.Activity) |> Enum.find(&(&1.actor == user.ap_id))