debian-mirror-gitlab/app/services/notes/post_process_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.2 KiB
Ruby
Raw Permalink Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2016-04-02 18:10:28 +05:30
module Notes
class PostProcessService
attr_accessor :note
def initialize(note)
@note = note
end
def execute
# Skip system notes, like status changes and cross-references and awards
2020-07-28 23:09:34 +05:30
unless note.system?
EventCreateService.new.leave_note(note, note.author)
2017-08-17 22:00:37 +05:30
2020-07-28 23:09:34 +05:30
return if note.for_personal_snippet?
2017-08-17 22:00:37 +05:30
2020-07-28 23:09:34 +05:30
note.create_cross_references!
::SystemNoteService.design_discussion_added(note) if create_design_discussion_system_note?
2020-05-24 23:13:21 +05:30
2016-04-02 18:10:28 +05:30
execute_note_hooks
end
end
2020-05-24 23:13:21 +05:30
private
def create_design_discussion_system_note?
2020-07-28 23:09:34 +05:30
note && note.for_design? && note.start_of_discussion?
2020-05-24 23:13:21 +05:30
end
2016-04-02 18:10:28 +05:30
def hook_data
2020-07-28 23:09:34 +05:30
Gitlab::DataBuilder::Note.build(note, note.author)
2016-04-02 18:10:28 +05:30
end
def execute_note_hooks
2020-07-28 23:09:34 +05:30
return unless note.project
2018-05-09 12:01:36 +05:30
2016-04-02 18:10:28 +05:30
note_data = hook_data
2020-07-28 23:09:34 +05:30
hooks_scope = note.confidential?(include_noteable: true) ? :confidential_note_hooks : :note_hooks
2018-04-05 14:03:07 +05:30
2020-07-28 23:09:34 +05:30
note.project.execute_hooks(note_data, hooks_scope)
2021-09-30 23:02:18 +05:30
note.project.execute_integrations(note_data, hooks_scope)
2016-04-02 18:10:28 +05:30
end
end
end
2019-12-26 22:10:19 +05:30
2021-06-08 01:23:25 +05:30
Notes::PostProcessService.prepend_mod_with('Notes::PostProcessService')