ticket_create_screen_job.rb 870 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
  2. class TicketCreateScreenJob < ApplicationJob
  3. include HasActiveJobLock
  4. def perform
  5. Sessions.list.each do |client_id, data|
  6. next if client_id.blank?
  7. user_id = data&.dig(:user, 'id')
  8. next if user_id.blank?
  9. user = User.lookup(id: user_id)
  10. next if !user&.permissions?('ticket.agent')
  11. # get attributes to update
  12. ticket_create_attributes = Ticket::ScreenOptions.attributes_to_change(
  13. current_user: user,
  14. )
  15. # no data exists
  16. next if ticket_create_attributes.blank?
  17. Rails.logger.debug { "push ticket_create for user #{user.id}" }
  18. Sessions.send(client_id, {
  19. event: 'ticket_create_attributes',
  20. data: ticket_create_attributes,
  21. })
  22. end
  23. end
  24. end