Files
chatwoot/app/jobs/notification/delete_notification_job.rb
2026-05-14 20:34:18 +05:30

16 lines
393 B
Ruby

class Notification::DeleteNotificationJob < ApplicationJob
queue_as :low
def perform(user, account, type: :all)
notifications = user.notifications.where(account_id: account.id)
ActiveRecord::Base.transaction do
if type == :all
notifications.destroy_all
elsif type == :read
notifications.where.not(read_at: nil).destroy_all
end
end
end
end