Class: Notes::DestroyService

Inherits:
BaseService show all
Defined in:
app/services/notes/destroy_service.rb

Constant Summary

Constants inherited from BaseService

BaseService::UnauthorizedError

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#clear_noteable_diffs_cache, #increment_usage_counter

Methods included from Gitlab::InternalEventsTracking

#track_internal_event

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#execute(note, old_note_body: nil) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument – used in EE override



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/services/notes/destroy_service.rb', line 5

def execute(note, old_note_body: nil) # rubocop:disable Lint/UnusedMethodArgument -- used in EE override
  TodoService.new.destroy_target(note) do |note|
    note.destroy
  end

  if note.for_merge_request?
    track_note_removal_usage_for_merge_requests(note)

    GraphqlTriggers.merge_request_merge_status_updated(note.noteable) if note.to_be_resolved?
  end

  clear_noteable_diffs_cache(note)

  if note.for_issue?
    track_note_removal_usage_for_issues(note)
    track_note_removal(note.noteable, Gitlab::WorkItems::Instrumentation::EventActions::NOTE_DESTROY)
  end

  if note.for_design?
    track_note_removal_usage_for_design(note)
    track_note_removal(note.noteable.issue, Gitlab::WorkItems::Instrumentation::EventActions::DESIGN_NOTE_DESTROY)
  end

  track_note_removal_usage_for_wiki(note) if note.for_wiki_page?
end