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

27 lines
718 B
Ruby
Raw Normal View History

2012-07-31 01:32:49 -04:00
module Notes
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
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)
# Create a cross-reference note if this Note contains GFM that names an
# issue, merge request, or commit.
note.references.each do |mentioned|
Note.create_cross_reference_note(mentioned, note.noteable, note.author, note.project)
end
end
end
2012-07-31 01:32:49 -04:00
note
end
end
end