update.rb 1.0 KB

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class Ticket::Update < BaseMutation
  4. include Gql::Mutations::Ticket::Concerns::HandlesGroup
  5. description 'Update a ticket.'
  6. argument :ticket_id, GraphQL::Types::ID, loads: Gql::Types::TicketType, description: 'The ticket to be updated'
  7. argument :input, Gql::Types::Input::Ticket::UpdateInputType, description: 'The ticket data'
  8. field :ticket, Gql::Types::TicketType, description: 'The updated ticket. If this is present but empty, the mutation was successful but the user has no rights to view the updated ticket.'
  9. def self.authorize(_obj, ctx)
  10. ctx.current_user.permissions?(['ticket.agent', 'ticket.customer'])
  11. end
  12. def resolve(ticket:, input:)
  13. return group_has_no_email_error if !group_has_email?(input: input)
  14. {
  15. ticket: Service::Ticket::Update
  16. .new(current_user: context.current_user)
  17. .execute(ticket: ticket, ticket_data: input)
  18. }
  19. end
  20. end
  21. end