triggers_subscriptions.rb 496 B

123456789101112131415161718192021
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. # Trigger GraphQL subscriptions on user device changes.
  3. module UserDevice::TriggersSubscriptions
  4. extend ActiveSupport::Concern
  5. included do
  6. after_commit :trigger_subscriptions
  7. end
  8. private
  9. def trigger_subscriptions
  10. Gql::Subscriptions::User::Current::DevicesUpdates.trigger(
  11. nil,
  12. arguments: {
  13. user_id: Gql::ZammadSchema.id_from_internal_id('User', user_id)
  14. }
  15. )
  16. end
  17. end