2012-07-31 01:32:49 -04:00
|
|
|
module Notes
|
2014-01-16 12:03:42 -05:00
|
|
|
class CreateService < BaseService
|
2012-07-31 01:32:49 -04:00
|
|
|
def execute
|
2014-06-17 15:09:01 -04:00
|
|
|
note = project.notes.new(params)
|
2012-07-31 01:32:49 -04:00
|
|
|
note.author = current_user
|
2014-02-20 07:07:42 -05:00
|
|
|
note.system = false
|
2014-06-17 15:09:01 -04:00
|
|
|
|
|
|
|
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)
|
2015-10-12 08:30:44 -04:00
|
|
|
note.create_cross_references!
|
2015-03-05 13:38:23 -05:00
|
|
|
execute_hooks(note)
|
2014-06-17 15:09:01 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-31 01:32:49 -04:00
|
|
|
note
|
|
|
|
end
|
2015-03-05 13:38:23 -05:00
|
|
|
|
|
|
|
def hook_data(note)
|
|
|
|
Gitlab::NoteDataBuilder.build(note, current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute_hooks(note)
|
|
|
|
note_data = hook_data(note)
|
2015-05-16 02:33:31 -04:00
|
|
|
note.project.execute_hooks(note_data, :note_hooks)
|
2015-03-05 13:38:23 -05:00
|
|
|
note.project.execute_services(note_data, :note_hooks)
|
|
|
|
end
|
2012-07-31 01:32:49 -04:00
|
|
|
end
|
|
|
|
end
|