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

48 lines
1.2 KiB
Ruby
Raw 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
unless @note.system?
2016-04-02 18:10:28 +05:30
EventCreateService.new.leave_note(@note, @note.author)
2017-08-17 22:00:37 +05:30
2018-05-09 12:01:36 +05:30
return if @note.for_personal_snippet?
2017-08-17 22:00:37 +05:30
2016-04-02 18:10:28 +05:30
@note.create_cross_references!
2020-05-24 23:13:21 +05:30
::SystemNoteService.design_discussion_added(@note) if create_design_discussion_system_note?
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?
@note && @note.for_design? && @note.start_of_discussion?
end
2016-04-02 18:10:28 +05:30
def hook_data
2016-09-13 17:45:13 +05:30
Gitlab::DataBuilder::Note.build(@note, @note.author)
2016-04-02 18:10:28 +05:30
end
def execute_note_hooks
2018-05-09 12:01:36 +05:30
return unless @note.project
2016-04-02 18:10:28 +05:30
note_data = hook_data
2020-06-23 00:09:42 +05:30
hooks_scope = @note.confidential?(include_noteable: true) ? :confidential_note_hooks : :note_hooks
2018-04-05 14:03:07 +05:30
@note.project.execute_hooks(note_data, hooks_scope)
@note.project.execute_services(note_data, hooks_scope)
2016-04-02 18:10:28 +05:30
end
end
end
2019-12-26 22:10:19 +05:30
Notes::PostProcessService.prepend_if_ee('EE::Notes::PostProcessService')