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

40 lines
936 B
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!
execute_note_hooks
end
end
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
2018-04-05 14:03:07 +05:30
hooks_scope = @note.confidential? ? :confidential_note_hooks : :note_hooks
@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')