retry_security_process.rb 941 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class Ticket::Article::RetrySecurityProcess < BaseMutation
  4. description "Retry an article's security process."
  5. argument :article_id, GraphQL::Types::ID, loads: Gql::Types::Ticket::ArticleType, description: 'Retry the security process for this article.'
  6. field :retry_result, Gql::Types::Ticket::Article::SecurityStateType, description: 'Result of the operation.'
  7. field :article, Gql::Types::Ticket::ArticleType, description: 'Updated article (article is not updated in case of an error result).'
  8. def self.authorize(_obj, ctx)
  9. ctx.current_user.permissions?('ticket.agent')
  10. end
  11. def authorized?(article:)
  12. Pundit.authorize(context.current_user, article, :update?)
  13. end
  14. def resolve(article:)
  15. { retry_result: SecureMailing.retry(article)&.first, article: article.reload }
  16. end
  17. end
  18. end