%{
id: Pleroma.ScheduledActivityWorker,
start: {Pleroma.ScheduledActivityWorker, :start_link, []}
+ },
+ %{
+ id: Pleroma.QuantumScheduler,
+ start: {Pleroma.QuantumScheduler, :start_link, []}
}
] ++
hackney_pool_children() ++
start: {Pleroma.Web.Endpoint, :start_link, []},
type: :supervisor
},
- %{id: Pleroma.Gopher.Server, start: {Pleroma.Gopher.Server, :start_link, []}},
- %{
- id: Pleroma.User.SynchronizationWorker,
- start: {Pleroma.User.SynchronizationWorker, :start_link, []}
- }
+ %{id: Pleroma.Gopher.Server, start: {Pleroma.Gopher.Server, :start_link, []}}
]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
- Supervisor.start_link(children, opts)
+ result = Supervisor.start_link(children, opts)
+ :ok = after_supervisor_start()
+ result
end
defp setup_instrumenters do
:hackney_pool.child_spec(pool, options)
end
end
+
+ defp after_supervisor_start do
+ with digest_config <- Application.get_env(:pleroma, :email_notifications)[:digest],
+ true <- digest_config[:active],
+ %Crontab.CronExpression{} = schedule <-
+ Crontab.CronExpression.Parser.parse!(digest_config[:schedule]) do
+ Pleroma.QuantumScheduler.new_job()
+ |> Quantum.Job.set_name(:digest_emails)
+ |> Quantum.Job.set_schedule(schedule)
+ |> Quantum.Job.set_task(&Pleroma.DigestEmailWorker.run/0)
+ |> Pleroma.QuantumScheduler.add_job()
+ end
+
+ :ok
+ end
end