summaryrefslogtreecommitdiff
path: root/lib/api/notes.rb
diff options
context:
space:
mode:
authoruran <uran@zeoalliance.com>2014-09-02 18:12:13 +0300
committeryglukhov <yuriy.glukhov@gmail.com>2014-12-25 14:28:40 +0200
commit1fbc01024123c44740e1c94cab5a74faf2856a21 (patch)
tree2bb5982d2a0ed22e7caf8cc5b6e5e87b6d1abe13 /lib/api/notes.rb
parentfe104386b16a73cbac1588aa5cce8319c6355ee9 (diff)
downloadgitlab-ce-1fbc01024123c44740e1c94cab5a74faf2856a21.tar.gz
Implemented notes (body) patching in API.
Diffstat (limited to 'lib/api/notes.rb')
-rw-r--r--lib/api/notes.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/api/notes.rb b/lib/api/notes.rb
index 0ef9a3c4beb..b29c054a044 100644
--- a/lib/api/notes.rb
+++ b/lib/api/notes.rb
@@ -64,6 +64,39 @@ module API
not_found!
end
end
+
+ # Modify existing +noteable+ note
+ #
+ # Parameters:
+ # id (required) - The ID of a project
+ # noteable_id (required) - The ID of an issue or snippet
+ # node_id (required) - The ID of a note
+ # body (required) - New content of a note
+ # Example Request:
+ # PUT /projects/:id/issues/:noteable_id/notes/:note_id
+ # PUT /projects/:id/snippets/:noteable_id/notes/:node_id
+ put ":id/#{noteables_str}/:#{noteable_id_str}/notes/:note_id" do
+ required_attributes! [:body]
+
+ authorize! :admin_note, user_project.notes.find(params[:note_id])
+
+ opts = {
+ note: params[:body],
+ note_id: params[:note_id],
+ noteable_type: noteables_str.classify,
+ noteable_id: params[noteable_id_str]
+ }
+
+ @note = ::Notes::UpdateService.new(user_project, current_user,
+ opts).execute
+
+ if @note.valid?
+ present @note, with: Entities::Note
+ else
+ bad_request!('Invalid note')
+ end
+ end
+
end
end
end