Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85828185
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/changelog.d/email_digest.fix b/changelog.d/email_digest.fix
new file mode 100644
index 000000000..cd15874a2
--- /dev/null
+++ b/changelog.d/email_digest.fix
@@ -0,0 +1 @@
+Fix the daily email digest job which was not executing
diff --git a/lib/pleroma/workers/cron/digest_emails_worker.ex b/lib/pleroma/workers/cron/digest_emails_worker.ex
index b50b52a7b..5cb13f5f9 100644
--- a/lib/pleroma/workers/cron/digest_emails_worker.ex
+++ b/lib/pleroma/workers/cron/digest_emails_worker.ex
@@ -1,64 +1,64 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.Cron.DigestEmailsWorker do
@moduledoc """
The worker to send digest emails.
"""
- use Oban.Worker, queue: "mailer"
+ use Oban.Worker, queue: :background
alias Pleroma.Config
alias Pleroma.Emails
alias Pleroma.Repo
alias Pleroma.User
import Ecto.Query
require Logger
@impl true
def perform(_job) do
config = Config.get([:email_notifications, :digest])
if config[:active] do
negative_interval = -Map.fetch!(config, :interval)
inactivity_threshold = Map.fetch!(config, :inactivity_threshold)
inactive_users_query = User.list_inactive_users_query(inactivity_threshold)
now = NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second)
from(u in inactive_users_query,
where: fragment(~s(? ->'digest' @> 'true'), u.email_notifications),
where: not is_nil(u.email),
where: u.last_digest_emailed_at < datetime_add(^now, ^negative_interval, "day"),
select: u
)
|> Repo.all()
|> send_emails
end
:ok
end
def send_emails(users) do
Enum.each(users, &send_email/1)
end
@doc """
Send digest email to the given user.
Updates `last_digest_emailed_at` field for the user and returns the updated user.
"""
@spec send_email(User.t()) :: User.t()
def send_email(user) do
with %Swoosh.Email{} = email <- Emails.UserEmail.digest_email(user) do
Emails.Mailer.deliver_async(email)
end
User.touch_last_digest_emailed_at(user)
end
@impl true
def timeout(_job), do: :timer.seconds(5)
end
diff --git a/priv/repo/migrations/20260401185429_cleanup_stale_digest_email_jobs.exs b/priv/repo/migrations/20260401185429_cleanup_stale_digest_email_jobs.exs
new file mode 100644
index 000000000..882c7ec66
--- /dev/null
+++ b/priv/repo/migrations/20260401185429_cleanup_stale_digest_email_jobs.exs
@@ -0,0 +1,9 @@
+defmodule Pleroma.Repo.Migrations.CleanupStaleDigestEmailJobs do
+ use Ecto.Migration
+
+ def up do
+ execute(
+ "DELETE from oban_jobs WHERE queue = 'mailer' AND worker = 'Pleroma.Workers.Cron.DigestEmailsWorker'"
+ )
+ end
+end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Oct 31, 3:41 AM (18 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1800991
Default Alt Text
(2 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline