summaryrefslogtreecommitdiff
path: root/app/services/notes/destroy_service.rb
blob: 2b6ec47eaef8df4828dd49a0fe3b165c8a80ec6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

module Notes
  class DestroyService < ::Notes::BaseService
    def execute(note)
      TodoService.new.destroy_target(note) do |note|
        note.destroy
      end

      clear_noteable_diffs_cache(note)
      track_note_removal_usage_for_issues(note) if note.for_issue?
    end

    private

    def track_note_removal_usage_for_issues(note)
      Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_comment_removed_action(author: note.author)
    end
  end
end

Notes::DestroyService.prepend_if_ee('EE::Notes::DestroyService')