reset_notifications_preferences_job.rb 589 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ResetNotificationsPreferencesJob < ApplicationJob
  3. include HasActiveJobLock
  4. # @param send_to_when_done [Integer] ID of user to notify after job is done
  5. def perform(send_to_when_done: nil)
  6. users_scope.find_each do |user|
  7. User.reset_notifications_preferences! user
  8. end
  9. return if !send_to_when_done
  10. Sessions.send_to(send_to_when_done, { event: 'ticket_agent_default_notifications_applied' })
  11. end
  12. private
  13. def users_scope
  14. User.with_permissions 'ticket.agent'
  15. end
  16. end