2018-12-25 04:48:26 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Releases
|
2020-10-06 11:08:33 -04:00
|
|
|
class DestroyService < Releases::BaseService
|
2018-12-25 04:48:26 -05:00
|
|
|
def execute
|
|
|
|
return error('Release does not exist', 404) unless release
|
|
|
|
return error('Access Denied', 403) unless allowed?
|
|
|
|
|
2021-07-05 05:07:37 -04:00
|
|
|
track_protected_tag_access_error!
|
|
|
|
|
2018-12-25 04:48:26 -05:00
|
|
|
if release.destroy
|
|
|
|
success(tag: existing_tag, release: release)
|
|
|
|
else
|
|
|
|
error(release.errors.messages || '400 Bad request', 400)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def allowed?
|
|
|
|
Ability.allowed?(current_user, :destroy_release, release)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|