checklist_updates.rb 982 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Subscriptions
  3. class Ticket::ChecklistUpdates < BaseSubscription
  4. include Gql::Concerns::EnsuresChecklistFeatureActive
  5. description 'Subscription for ticket checklist changes.'
  6. argument :ticket_id, GraphQL::Types::ID, description: 'Ticket identifier'
  7. field :ticket_checklist, Gql::Types::ChecklistType, description: 'Ticket checklist'
  8. field :removed_ticket_checklist, Boolean, description: 'Ticket checklist was removed from ticket'
  9. def self.authorize(_obj, ctx)
  10. ensure_checklist_feature_active!
  11. super
  12. end
  13. def authorized?(ticket_id:)
  14. context.current_user.permissions?('ticket.agent') && Gql::ZammadSchema.authorized_object_from_id(ticket_id, type: ::Ticket, user: context.current_user)
  15. end
  16. def update(ticket_id:)
  17. return { removed_ticket_checklist: true } if object.nil?
  18. { ticket_checklist: object }
  19. end
  20. end
  21. end