diff options
author | Nihad Abbasov <narkoz.2008@gmail.com> | 2012-11-29 12:06:24 -0800 |
---|---|---|
committer | Nihad Abbasov <narkoz.2008@gmail.com> | 2012-11-29 12:11:00 -0800 |
commit | c946bf886c2c07491a4595e93861df02dbf809f4 (patch) | |
tree | bc0000976ee2da129ab3ecbf7d47b56bb5ffcd92 /lib/api/notes.rb | |
parent | 1c5aa848ce6141b8679e167171096055dc7f4df3 (diff) | |
download | gitlab-ce-c946bf886c2c07491a4595e93861df02dbf809f4.tar.gz |
API: create new notes
Diffstat (limited to 'lib/api/notes.rb')
-rw-r--r-- | lib/api/notes.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/api/notes.rb b/lib/api/notes.rb index 84b6beb5c71..924eeaa3618 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -48,6 +48,28 @@ module Gitlab @note = @noteable.notes.find(params[:note_id]) present @note, with: Entities::Note end + + # Create a new +noteable+ note + # + # Parameters: + # id (required) - The ID or code name of a project + # noteable_id (required) - The ID of an issue or snippet + # body (required) - The content of a note + # Example Request: + # POST /projects/:id/issues/:noteable_id/notes + # POST /projects/:id/snippets/:noteable_id/notes + post ":id/#{noteables_str}/:#{noteable_id_str}/notes" do + @noteable = user_project.send(:"#{noteables_str}").find(params[:"#{noteable_id_str}"]) + @note = @noteable.notes.new(note: params[:body]) + @note.author = current_user + @note.project = user_project + + if @note.save + present @note, with: Entities::Note + else + not_found! + end + end end end end |