triggers_subscriptions.rb 877 B

12345678910111213141516171819202122232425
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. # Trigger GraphQL subscriptions on ticket changes.
  3. module Taskbar::TriggersSubscriptions
  4. extend ActiveSupport::Concern
  5. included do
  6. after_commit :trigger_subscriptions
  7. end
  8. private
  9. def trigger_subscriptions
  10. return true if !saved_change_to_attribute?('preferences')
  11. # For now it's only needed in the mobile view context.
  12. return true if !app.eql?('mobile') && !persisted?
  13. Gql::Subscriptions::TicketLiveUserUpdates.trigger(self, arguments: {
  14. user_id: Gql::ZammadSchema.id_from_internal_id('User', user_id),
  15. key: key,
  16. app: app,
  17. })
  18. end
  19. end