BigW Consortium Gitlab

Commit 312a09e7 by Rémy Coutable

Merge branch 'api-expose-subscribed' into 'master'

API: Expose subscribed? on issues and merge requests This is the first start for the new `subscribable` API. It exposes the `subscribed` field for issues and merge requests. Related to #6024 See merge request !3611
parents 4d04e918 fb2fde9d
......@@ -12,6 +12,7 @@ v 8.7.0 (unreleased)
- Allow back dating on issues when created through the API
- Fix Error 500 after renaming a project path (Stan Hu)
- Fix avatar stretching by providing a cropping feature
- API: Expose `subscribed` for issues and merge requests (Robert Schilling)
- Allow SAML to handle external users based on user's information !3530
- Add endpoints to archive or unarchive a project !3372
- Add links to CI setup documentation from project settings and builds pages
......
......@@ -76,8 +76,9 @@ Example response:
"title" : "Consequatur vero maxime deserunt laboriosam est voluptas dolorem.",
"created_at" : "2016-01-04T15:31:51.081Z",
"iid" : 6,
"labels" : []
},
"labels" : [],
"subscribed" : false
}
]
```
......@@ -152,7 +153,8 @@ Example response:
"id" : 41,
"title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
"updated_at" : "2016-01-04T15:31:46.176Z",
"created_at" : "2016-01-04T15:31:46.176Z"
"created_at" : "2016-01-04T15:31:46.176Z",
"subscribed" : false
}
]
```
......@@ -213,7 +215,8 @@ Example response:
"id" : 41,
"title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
"updated_at" : "2016-01-04T15:31:46.176Z",
"created_at" : "2016-01-04T15:31:46.176Z"
"created_at" : "2016-01-04T15:31:46.176Z",
"subscribed": false
}
```
......@@ -267,7 +270,8 @@ Example response:
},
"description" : null,
"updated_at" : "2016-01-07T12:44:33.959Z",
"milestone" : null
"milestone" : null,
"subscribed" : true
}
```
......@@ -323,7 +327,8 @@ Example response:
],
"id" : 85,
"assignee" : null,
"milestone" : null
"milestone" : null,
"subscribed" : true
}
```
......
......@@ -66,7 +66,8 @@ Parameters:
"due_date": null
},
"merge_when_build_succeeds": true,
"merge_status": "can_be_merged"
"merge_status": "can_be_merged",
"subscribed" : false
}
]
```
......@@ -128,7 +129,8 @@ Parameters:
"due_date": null
},
"merge_when_build_succeeds": true,
"merge_status": "can_be_merged"
"merge_status": "can_be_merged",
"subscribed" : true
}
```
......@@ -227,6 +229,7 @@ Parameters:
},
"merge_when_build_succeeds": true,
"merge_status": "can_be_merged",
"subscribed" : true,
"changes": [
{
"old_path": "VERSION",
......@@ -304,7 +307,8 @@ Parameters:
"due_date": null
},
"merge_when_build_succeeds": true,
"merge_status": "can_be_merged"
"merge_status": "can_be_merged",
"subscribed" : true
}
```
......@@ -373,7 +377,8 @@ Parameters:
"due_date": null
},
"merge_when_build_succeeds": true,
"merge_status": "can_be_merged"
"merge_status": "can_be_merged",
"subscribed" : true
}
```
......@@ -466,7 +471,8 @@ Parameters:
"due_date": null
},
"merge_when_build_succeeds": true,
"merge_status": "can_be_merged"
"merge_status": "can_be_merged",
"subscribed" : true
}
```
......@@ -530,7 +536,8 @@ Parameters:
"due_date": null
},
"merge_when_build_succeeds": true,
"merge_status": "can_be_merged"
"merge_status": "can_be_merged",
"subscribed" : true
}
```
......
......@@ -170,6 +170,10 @@ module API
expose :label_names, as: :labels
expose :milestone, using: Entities::Milestone
expose :assignee, :author, using: Entities::UserBasic
expose :subscribed do |issue, options|
issue.subscribed?(options[:current_user])
end
end
class MergeRequest < ProjectEntity
......@@ -183,6 +187,10 @@ module API
expose :milestone, using: Entities::Milestone
expose :merge_when_build_succeeds
expose :merge_status
expose :subscribed do |merge_request, options|
merge_request.subscribed?(options[:current_user])
end
end
class MergeRequestChanges < MergeRequest
......
......@@ -55,7 +55,7 @@ module API
issues = filter_issues_state(issues, params[:state]) unless params[:state].nil?
issues = filter_issues_labels(issues, params[:labels]) unless params[:labels].nil?
issues.reorder(issuable_order_by => issuable_sort)
present paginate(issues), with: Entities::Issue
present paginate(issues), with: Entities::Issue, current_user: current_user
end
end
......@@ -92,7 +92,7 @@ module API
end
issues.reorder(issuable_order_by => issuable_sort)
present paginate(issues), with: Entities::Issue
present paginate(issues), with: Entities::Issue, current_user: current_user
end
# Get a single project issue
......@@ -105,7 +105,7 @@ module API
get ":id/issues/:issue_id" do
@issue = user_project.issues.find(params[:issue_id])
not_found! unless can?(current_user, :read_issue, @issue)
present @issue, with: Entities::Issue
present @issue, with: Entities::Issue, current_user: current_user
end
# Create a new project issue
......@@ -149,7 +149,7 @@ module API
issue.add_labels_by_names(params[:labels].split(','))
end
present issue, with: Entities::Issue
present issue, with: Entities::Issue, current_user: current_user
else
render_validation_error!(issue)
end
......@@ -189,7 +189,7 @@ module API
issue.add_labels_by_names(params[:labels].split(','))
end
present issue, with: Entities::Issue
present issue, with: Entities::Issue, current_user: current_user
else
render_validation_error!(issue)
end
......
......@@ -56,7 +56,7 @@ module API
end
merge_requests = merge_requests.reorder(issuable_order_by => issuable_sort)
present paginate(merge_requests), with: Entities::MergeRequest
present paginate(merge_requests), with: Entities::MergeRequest, current_user: current_user
end
# Create MR
......@@ -94,7 +94,7 @@ module API
merge_request.add_labels_by_names(params[:labels].split(","))
end
present merge_request, with: Entities::MergeRequest
present merge_request, with: Entities::MergeRequest, current_user: current_user
else
handle_merge_request_errors! merge_request.errors
end
......@@ -130,7 +130,7 @@ module API
authorize! :read_merge_request, merge_request
present merge_request, with: Entities::MergeRequest
present merge_request, with: Entities::MergeRequest, current_user: current_user
end
# Show MR commits
......@@ -162,7 +162,7 @@ module API
merge_request = user_project.merge_requests.
find(params[:merge_request_id])
authorize! :read_merge_request, merge_request
present merge_request, with: Entities::MergeRequestChanges
present merge_request, with: Entities::MergeRequestChanges, current_user: current_user
end
# Update MR
......@@ -204,7 +204,7 @@ module API
merge_request.add_labels_by_names(params[:labels].split(","))
end
present merge_request, with: Entities::MergeRequest
present merge_request, with: Entities::MergeRequest, current_user: current_user
else
handle_merge_request_errors! merge_request.errors
end
......@@ -246,7 +246,7 @@ module API
execute(merge_request)
end
present merge_request, with: Entities::MergeRequest
present merge_request, with: Entities::MergeRequest, current_user: current_user
end
# Cancel Merge if Merge When build succeeds is enabled
......@@ -325,7 +325,7 @@ module API
get "#{path}/closes_issues" do
merge_request = user_project.merge_requests.find(params[:merge_request_id])
issues = ::Kaminari.paginate_array(merge_request.closes_issues(current_user))
present paginate(issues), with: Entities::Issue
present paginate(issues), with: Entities::Issue, current_user: current_user
end
end
end
......
......@@ -103,7 +103,7 @@ module API
authorize! :read_milestone, user_project
@milestone = user_project.milestones.find(params[:milestone_id])
present paginate(@milestone.issues), with: Entities::Issue
present paginate(@milestone.issues), with: Entities::Issue, current_user: current_user
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment