template_updates.rb 692 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Subscriptions
  3. class TemplateUpdates < BaseSubscription
  4. description 'Updates to ticket templates'
  5. broadcastable true
  6. argument :only_active, Boolean, required: false, default_value: false, description: 'Fetch only active templates'
  7. field :templates, [Gql::Types::TemplateType, { null: false }], description: 'Current ticket templates'
  8. def authorized?(only_active:)
  9. context.current_user.permissions?(['ticket.agent', 'ticket.customer'])
  10. end
  11. def update(only_active:)
  12. {
  13. templates: only_active ? Template.active : Template.all
  14. }
  15. end
  16. end
  17. end