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

33 lines
806 B
Ruby
Raw Normal View History

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)
2015-11-26 14:37:03 +05:30
# Skip system notes, like status changes and cross-references and awards
unless note.system || note.is_award
2014-09-02 18:07:02 +05:30
event_service.leave_note(note, note.author)
2015-10-24 18:46:33 +05:30
note.create_cross_references!
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