diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-09 17:17:01 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-06-10 13:19:43 +0200 |
commit | beed70c0248fea13bdf727e5f14dee362b0cd298 (patch) | |
tree | 06a8fca1cf4dfcbd60b3dedfd96dda4adf778943 /lib/api | |
parent | d74a8900e27a98f1c921052d2fc44f38cc63a2ea (diff) | |
download | gitlab-ce-feature-flags.tar.gz |
Use feature flags for notes and award emojisfeature-flags
This allows us to disable creating/updating/removing of notes as well as
toggling of award emojis.
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/helpers.rb | 6 | ||||
-rw-r--r-- | lib/api/notes.rb | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 2aaa0557ea3..bae7f35a77d 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -281,6 +281,12 @@ module API error!({ 'message' => message }, status) end + def require_feature!(feature) + unless Gitlab::Feature.feature_enabled?(feature) + render_api_error!('503 Service Unavailable', 503) + end + end + # Projects helpers def filter_projects(projects) diff --git a/lib/api/notes.rb b/lib/api/notes.rb index d4fcfd3d4d3..eeb7e87a3bd 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -71,6 +71,7 @@ module API # POST /projects/:id/issues/:noteable_id/notes # POST /projects/:id/snippets/:noteable_id/notes post ":id/#{noteables_str}/:#{noteable_id_str}/notes" do + require_feature! :creating_notes required_attributes! [:body] opts = { @@ -103,6 +104,7 @@ module API # 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 + require_feature! :updating_notes required_attributes! [:body] note = user_project.notes.find(params[:note_id]) @@ -132,6 +134,7 @@ module API # DELETE /projects/:id/issues/:noteable_id/notes/:note_id # DELETE /projects/:id/snippets/:noteable_id/notes/:node_id delete ":id/#{noteables_str}/:#{noteable_id_str}/notes/:note_id" do + require_feature! :removing_notes note = user_project.notes.find(params[:note_id]) authorize! :admin_note, note |