MRF: create MRF.Policy behaviour separate from MRF module
[akkoma] / lib / pleroma / config / oban.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Config.Oban do
6 require Logger
7
8 def warn do
9 oban_config = Pleroma.Config.get(Oban)
10
11 crontab =
12 [
13 Pleroma.Workers.Cron.StatsWorker,
14 Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker,
15 Pleroma.Workers.Cron.ClearOauthTokenWorker
16 ]
17 |> Enum.reduce(oban_config[:crontab], fn removed_worker, acc ->
18 with acc when is_list(acc) <- acc,
19 setting when is_tuple(setting) <-
20 Enum.find(acc, fn {_, worker} -> worker == removed_worker end) do
21 """
22 !!!OBAN CONFIG WARNING!!!
23 You are using old workers in Oban crontab settings, which were removed.
24 Please, remove setting from crontab in your config file (prod.secret.exs): #{
25 inspect(setting)
26 }
27 """
28 |> Logger.warn()
29
30 List.delete(acc, setting)
31 else
32 _ -> acc
33 end
34 end)
35
36 Pleroma.Config.put(Oban, Keyword.put(oban_config, :crontab, crontab))
37 end
38 end