digest_mailer_worker.rb 383 B

123456789101112131415161718192021
  1. # frozen_string_literal: true
  2. class DigestMailerWorker
  3. include Sidekiq::Worker
  4. sidekiq_options queue: 'mailers'
  5. attr_reader :user
  6. def perform(user_id)
  7. @user = User.find(user_id)
  8. deliver_digest if @user.allows_digest_emails?
  9. end
  10. private
  11. def deliver_digest
  12. NotificationMailer.digest(user.account).deliver_now!
  13. user.touch(:last_emailed_at)
  14. end
  15. end