taskbar_update_trigger_subscriptions_job.rb 892 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. # This job retrieves all taskbars associated with the specified taskbar key and activates the related update subscription.
  3. # This allows for updates to taskbar entries, such as cases where a user may lose permissions for a ticket.
  4. class TaskbarUpdateTriggerSubscriptionsJob < ApplicationJob
  5. include HasActiveJobLock
  6. def lock_key
  7. # "TaskbarUpdateTriggerSubscriptionsJob/Ticket-123"
  8. "#{self.class.name}/#{arguments[0]}"
  9. end
  10. def perform(taskbar_key)
  11. # Trigger taskbar item updates in case the ticket group was changed.
  12. # This will make sure a timely update about the loss or gain of ticket access for the client.
  13. Taskbar.where(key: taskbar_key, app: :desktop).each do |taskbar|
  14. Gql::Subscriptions::User::Current::TaskbarItemUpdates.trigger_after_update(taskbar)
  15. end
  16. end
  17. end