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/scheduler/defang_scheduler.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/workers/scheduler/defang_scheduler.rb b/app/workers/scheduler/defang_scheduler.rb
new file mode 100644
index 000000000..a20242a23
--- /dev/null
+++ b/app/workers/scheduler/defang_scheduler.rb
@@ -0,0 +1,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