2020-08-20 20:10:44 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module IssuableLinks
|
|
|
|
class DestroyService < BaseService
|
2020-09-10 17:08:28 -04:00
|
|
|
include IncidentManagement::UsageData
|
|
|
|
|
2020-08-20 20:10:44 -04:00
|
|
|
attr_reader :link, :current_user
|
|
|
|
|
|
|
|
def initialize(link, user)
|
|
|
|
@link = link
|
|
|
|
@current_user = user
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
|
|
|
return error(not_found_message, 404) unless permission_to_remove_relation?
|
|
|
|
|
|
|
|
remove_relation
|
|
|
|
create_notes
|
2020-09-10 17:08:28 -04:00
|
|
|
track_event
|
2020-08-20 20:10:44 -04:00
|
|
|
|
|
|
|
success(message: 'Relation was removed')
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def remove_relation
|
|
|
|
link.destroy!
|
|
|
|
end
|
|
|
|
|
|
|
|
def not_found_message
|
|
|
|
'No Issue Link found'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|