ticket_online_notification_seen_job.rb 623 B

123456789101112131415161718192021
  1. class TicketOnlineNotificationSeenJob < ApplicationJob
  2. def perform(ticket_id, user_id)
  3. user_id = user_id || 1
  4. # set all online notifications to seen
  5. Transaction.execute do
  6. ticket = Ticket.lookup(id: ticket_id)
  7. OnlineNotification.list_by_object('Ticket', ticket_id).each do |notification|
  8. next if notification.seen
  9. seen = ticket.online_notification_seen_state(notification.user_id)
  10. next if !seen
  11. next if seen == notification.seen
  12. notification.seen = true
  13. notification.updated_by_id = user_id
  14. notification.save!
  15. end
  16. end
  17. end
  18. end