remove.rb 750 B

123456789101112131415161718192021
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class Form::UploadCache::Remove < BaseMutation
  4. include Gql::Mutations::Form::UploadCache::Concerns::HandlesAuthorization
  5. description 'Remove uploaded files for a form'
  6. argument :form_id, Gql::Types::FormIdType, 'FormID for the uploads.'
  7. argument :file_ids, [GraphQL::Types::ID], 'Files to be uploaded.'
  8. field :success, Boolean, null: false, description: 'Was the mutation successful?'
  9. def resolve(form_id:, file_ids:)
  10. cache = UploadCache.new(form_id)
  11. file_ids.map { |file_id| cache.remove_item(Gql::ZammadSchema.verified_object_from_id(file_id, type: ::Store).id) }
  12. { success: true }
  13. end
  14. end
  15. end