24 lines
712 B
Ruby
24 lines
712 B
Ruby
require "my_smsa_pio/notifications/ntfy/publisher"
|
|
|
|
class SendNtfyNotificationJob < ApplicationJob
|
|
queue_as :notifications
|
|
retry_on StandardError, wait: :exponentially_longer, attempts: 3
|
|
|
|
def perform(admin_id, event_type, title:, message:, priority: 3, tags: [], click: nil)
|
|
admin = AdminUser.find_by(id: admin_id)
|
|
return unless admin
|
|
return unless admin.ntfy_configured?
|
|
|
|
MySmsaPio::Notifications::Ntfy::Publisher.new(admin).publish(
|
|
title: title,
|
|
message: message,
|
|
priority: priority,
|
|
tags: tags,
|
|
click: click
|
|
)
|
|
rescue StandardError => e
|
|
Rails.logger.error("SendNtfyNotificationJob failed for admin #{admin_id}: #{e.message}")
|
|
raise
|
|
end
|
|
end
|