triggers_subscriptions.rb 495 B

1234567891011121314151617
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. # Trigger GraphQL subscriptions on user changes.
  3. module OnlineNotification::TriggersSubscriptions
  4. extend ActiveSupport::Concern
  5. included do
  6. after_save :trigger_subscriptions
  7. after_destroy :trigger_subscriptions
  8. end
  9. def trigger_subscriptions
  10. Gql::Subscriptions::OnlineNotificationsCount
  11. .trigger(user,
  12. arguments: { user_id: Gql::ZammadSchema.id_from_object(user) })
  13. end
  14. end