gitlab-org--gitlab-foss/app/services/notes/post_process_service.rb

38 lines
862 B
Ruby
Raw Normal View History

# frozen_string_literal: true
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
2016-06-01 05:23:09 -04:00
unless @note.system?
EventCreateService.new.leave_note(@note, @note.author)
2017-01-20 05:28:40 -05:00
return if @note.for_personal_snippet?
2017-01-20 05:28:40 -05:00
@note.create_cross_references!
execute_note_hooks
end
end
def hook_data
Gitlab::DataBuilder::Note.build(@note, @note.author)
end
def execute_note_hooks
return unless @note.project
note_data = hook_data
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)
end
end
end