feat(ntfy): add NtfyDispatchable concern for fanning out to admins
This commit is contained in:
21
app/models/concerns/ntfy_dispatchable.rb
Normal file
21
app/models/concerns/ntfy_dispatchable.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
module NtfyDispatchable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def dispatch_ntfy(event_type, title:, message:, priority: 3, tags: [], click: nil)
|
||||
AdminUser.where(ntfy_enabled: true).find_each do |admin|
|
||||
next unless admin.ntfy_configured?
|
||||
|
||||
SendNtfyNotificationJob.perform_later(
|
||||
admin.id,
|
||||
event_type,
|
||||
title: title,
|
||||
message: message,
|
||||
priority: priority,
|
||||
tags: tags,
|
||||
click: click
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user