signature.rb 848 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Queries
  3. class Ticket::Signature < BaseQuery
  4. description 'Fetch a ticket signature by group ID'
  5. argument :group_id, GraphQL::Types::ID, description: 'The group of the ticket.', loads: Gql::Types::GroupType
  6. argument :ticket_id, GraphQL::Types::ID, required: false, description: 'Current ticket.', loads: Gql::Types::TicketType
  7. type Gql::Types::SignatureType, null: true
  8. def resolve(group:, ticket: nil)
  9. begin
  10. signature = group_signature(group)
  11. rescue ActiveRecord::RecordNotFound
  12. return nil
  13. end
  14. return nil if !signature.active?
  15. return nil if !signature.body?
  16. signature
  17. end
  18. private
  19. def group_signature(group)
  20. Signature.find(group.signature_id)
  21. end
  22. end
  23. end