logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

email_scheduler.rb (593B)


  1. # frozen_string_literal: true
  2. require 'sidekiq-scheduler'
  3. class Scheduler::EmailScheduler
  4. include Sidekiq::Worker
  5. def perform
  6. eligible_users.find_each do |user|
  7. next unless user.allows_digest_emails?
  8. DigestMailerWorker.perform_async(user.id)
  9. end
  10. end
  11. private
  12. def eligible_users
  13. User.confirmed
  14. .joins(:account)
  15. .where(accounts: { silenced: false, suspended: false })
  16. .where(disabled: false)
  17. .where('current_sign_in_at < ?', 20.days.ago)
  18. .where('last_emailed_at IS NULL OR last_emailed_at < ?', 20.days.ago)
  19. end
  20. end