2020-08-21 00:10:44 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module IssuableLinks
|
|
|
|
class DestroyService < BaseService
|
2020-09-10 21:08:28 +00:00
|
|
|
include IncidentManagement::UsageData
|
|
|
|
|
2020-08-21 00:10:44 +00: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 21:08:28 +00:00
|
|
|
track_event
|
2020-08-21 00:10:44 +00: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
|