2018-07-17 12:50:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-05 19:21:02 -04:00
|
|
|
module Notes
|
2018-10-16 12:21:16 -04:00
|
|
|
class DestroyService < ::Notes::BaseService
|
2016-04-05 19:21:02 -04:00
|
|
|
def execute(note)
|
2017-12-08 07:17:22 -05:00
|
|
|
TodoService.new.destroy_target(note) do |note|
|
|
|
|
note.destroy
|
|
|
|
end
|
2018-10-16 12:21:16 -04:00
|
|
|
|
|
|
|
clear_noteable_diffs_cache(note)
|
2020-10-23 05:08:41 -04:00
|
|
|
track_note_removal_usage_for_issues(note) if note.for_issue?
|
2021-01-11 04:10:46 -05:00
|
|
|
track_note_removal_usage_for_merge_requests(note) if note.for_merge_request?
|
2020-10-23 05:08:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def track_note_removal_usage_for_issues(note)
|
|
|
|
Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_removed_action(author: note.author)
|
2016-04-05 19:21:02 -04:00
|
|
|
end
|
2021-01-11 04:10:46 -05:00
|
|
|
|
|
|
|
def track_note_removal_usage_for_merge_requests(note)
|
2021-01-14 16:10:37 -05:00
|
|
|
Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter.track_remove_comment_action(note: note)
|
2021-01-11 04:10:46 -05:00
|
|
|
end
|
2016-04-05 19:21:02 -04:00
|
|
|
end
|
|
|
|
end
|
2020-01-16 07:08:32 -05:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
Notes::DestroyService.prepend_mod_with('Notes::DestroyService')
|