summaryrefslogtreecommitdiff
path: root/lib/api/projects.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-04-13 15:05:21 +0000
committerRémy Coutable <remy@rymai.me>2016-04-13 15:05:21 +0000
commit94e130cec30a8cfa6687d254e1cabce568a22634 (patch)
treef92966b9197edc7360c94de457341c3f086e7a42 /lib/api/projects.rb
parenteebd7533ea780dade5e953b05c83c7b87f4bbf6f (diff)
parent54231aa4e036179d035ddd3641bc15a5b31883f2 (diff)
downloadgitlab-ce-94e130cec30a8cfa6687d254e1cabce568a22634.tar.gz
Merge branch 'api-star-project' into 'master'
API: Star and unstar a project Add two new endpoints `POST /projects/:id/star` and `POST /projects/:id/unstar` to star and unstar a project. * Closes #12739 See merge request !3578
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r--lib/api/projects.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 24b31005475..cc2c7a0c503 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -272,6 +272,40 @@ module API
present user_project, with: Entities::Project
end
+ # Star project
+ #
+ # Parameters:
+ # id (required) - The ID of a project
+ # Example Request:
+ # POST /projects/:id/star
+ post ':id/star' do
+ if current_user.starred?(user_project)
+ not_modified!
+ else
+ current_user.toggle_star(user_project)
+ user_project.reload
+
+ present user_project, with: Entities::Project
+ end
+ end
+
+ # Unstar project
+ #
+ # Parameters:
+ # id (required) - The ID of a project
+ # Example Request:
+ # DELETE /projects/:id/star
+ delete ':id/star' do
+ if current_user.starred?(user_project)
+ current_user.toggle_star(user_project)
+ user_project.reload
+
+ present user_project, with: Entities::Project
+ else
+ not_modified!
+ end
+ end
+
# Remove project
#
# Parameters: