2014-09-02 18:07:02 +05:30
|
|
|
module Notes
|
|
|
|
class CreateService < BaseService
|
|
|
|
def execute
|
|
|
|
note = project.notes.new(params)
|
|
|
|
note.author = current_user
|
|
|
|
note.system = false
|
|
|
|
|
|
|
|
if note.save
|
|
|
|
notification_service.new_note(note)
|
|
|
|
|
|
|
|
# Skip system notes, like status changes and cross-references.
|
|
|
|
unless note.system
|
|
|
|
event_service.leave_note(note, note.author)
|
|
|
|
|
|
|
|
# Create a cross-reference note if this Note contains GFM that names an
|
|
|
|
# issue, merge request, or commit.
|
|
|
|
note.references.each do |mentioned|
|
2015-09-11 14:41:01 +05:30
|
|
|
SystemNoteService.cross_reference(mentioned, note.noteable, note.author)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
execute_hooks(note)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
note
|
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
def hook_data(note)
|
|
|
|
Gitlab::NoteDataBuilder.build(note, current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute_hooks(note)
|
|
|
|
note_data = hook_data(note)
|
2015-09-11 14:41:01 +05:30
|
|
|
note.project.execute_hooks(note_data, :note_hooks)
|
2015-04-26 12:48:37 +05:30
|
|
|
note.project.execute_services(note_data, :note_hooks)
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|