debian-mirror-gitlab/app/graphql/mutations/uploads/delete.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
980 B
Ruby
Raw Normal View History

2022-08-27 11:52:29 +05:30
# frozen_string_literal: true
module Mutations
module Uploads
class Delete < BaseMutation
graphql_name 'UploadDelete'
description 'Deletes an upload.'
include Mutations::ResolvesResourceParent
authorize :destroy_upload
argument :secret, GraphQL::Types::String,
required: true,
description: 'Secret part of upload path.'
argument :filename, GraphQL::Types::String,
required: true,
description: 'Upload filename.'
field :upload, Types::UploadType,
null: true,
description: 'Deleted upload.'
def resolve(args)
parent = authorized_resource_parent_find!(args)
result = ::Uploads::DestroyService.new(parent, current_user).execute(args[:secret], args[:filename])
{
upload: result[:status] == :success ? result[:upload] : nil,
errors: Array(result[:message])
}
end
end
end
end