about summary refs log tree commit diff
path: root/app/workers/scheduler/defang_scheduler.rb
blob: ea999572d60f735d306e248dc832b9483c6c5a82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: true

class Scheduler::DefangScheduler
  include Sidekiq::Worker
  include ServiceAccountHelper

  def perform
    User.where(defanged: false, last_fanged_at: nil).or(User.where('last_fanged_at <= ?', 15.minutes.ago)) do |user|
      user.defang!
      next unless user&.account.present?
      service_dm('announcements', user.account, "You are no longer in #{user.role} mode.", footer: 'auto-defang')
    end
  end
end