Files
moreminimore-chat/app/jobs/notification/delete_notification_job.rb
Shivam Mishra 13f66e3a88 fix: incorrect scope across controllers (#14459)
Co-authored-by: Sojan Jose <sojan@pepalo.com>
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