about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/digest_mailer_worker.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/workers/digest_mailer_worker.rb b/app/workers/digest_mailer_worker.rb
new file mode 100644
index 000000000..dedb21e4e
--- /dev/null
+++ b/app/workers/digest_mailer_worker.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class DigestMailerWorker
+  include Sidekiq::Worker
+
+  sidekiq_options queue: 'mailers'
+
+  def perform(user_id)
+    user = User.find(user_id)
+    return unless user.settings.notification_emails['digest']
+    NotificationMailer.digest(user.account).deliver_now!
+    user.touch(:last_emailed_at)
+  end
+end