merge.rb 1.1 KB

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class Ticket::Merge < BaseMutation
  4. description 'Create a new ticket.'
  5. argument :source_ticket_id, GraphQL::Types::ID, loads: Gql::Types::TicketType, description: 'The (source) ticket that should be merged into another one'
  6. argument :target_ticket_id, GraphQL::Types::ID, loads: Gql::Types::TicketType, description: 'The (target) ticket that another ticket should be merged into'
  7. field :source_ticket, Gql::Types::TicketType, description: 'The source ticket after merging.'
  8. field :target_ticket, Gql::Types::TicketType, description: 'The target ticket after merging.'
  9. def self.authorize(_obj, ctx)
  10. ctx.current_user.permissions?('ticket.agent')
  11. end
  12. def resolve(source_ticket:, target_ticket:)
  13. Service::Ticket::Merge.new(current_user: context.current_user).execute(source_ticket: source_ticket, target_ticket: target_ticket)
  14. { source_ticket: source_ticket, target_ticket: target_ticket }
  15. rescue Exceptions::UnprocessableEntity => e
  16. error_response({ message: e.message })
  17. end
  18. end
  19. end