templates.rb 570 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Queries
  3. class Templates < BaseQuery
  4. description 'Fetch ticket templates'
  5. argument :only_active, Boolean, required: false, default_value: false, description: 'Fetch only active templates'
  6. type [Gql::Types::TemplateType, { null: false }], null: false
  7. def self.authorize(_obj, ctx)
  8. ctx.current_user.permissions?(['admin.template', 'ticket.agent'])
  9. end
  10. def resolve(only_active:)
  11. only_active ? Template.active : Template.all
  12. end
  13. end
  14. end