about summary refs log tree commit diff
path: root/app/workers/scheduler/defang_scheduler.rb
blob: a20242a23695c36cce2e6421edc7cfd3ef077b4a (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