remove.rb 671 B

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