diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-08-30 18:44:32 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-08-30 18:44:32 +0000 |
commit | b3b3bc2565cdf133ae38844d8df9ccf453bf0e5c (patch) | |
tree | b004e31b3f3eefea3efe9ea7d99b9fb6f59f094f /lib/api | |
parent | 51087cfa1a6b0bb5a7abf35081ed3b669253eb4f (diff) | |
parent | 76c2901eac89b1b3a9975ec0f91fb929fbed2e70 (diff) | |
download | gitlab-ce-b3b3bc2565cdf133ae38844d8df9ccf453bf0e5c.tar.gz |
Merge branch '19721-issues-created-through-api-do-not-notify-label-subscribers' into 'master'
user is now notified when creating an issue through the api
Previously when a issue was created through our API it would not mail label subscribers, this MR aims to fix that
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [x] API support added
- Tests
- [x] Added for this feature/bug
- [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
Closes #19721
See merge request !5720
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/issues.rb | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 077258faee1..d0bc7243e54 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -154,21 +154,15 @@ module API render_api_error!({ labels: errors }, 400) end - project = user_project + attrs[:labels] = params[:labels] if params[:labels] - issue = ::Issues::CreateService.new(project, current_user, attrs.merge(request: request, api: true)).execute + issue = ::Issues::CreateService.new(user_project, current_user, attrs.merge(request: request, api: true)).execute if issue.spam? render_api_error!({ error: 'Spam detected' }, 400) end if issue.valid? - # Find or create labels and attach to issue. Labels are valid because - # we already checked its name, so there can't be an error here - if params[:labels].present? - issue.add_labels_by_names(params[:labels].split(',')) - end - present issue, with: Entities::Issue, current_user: current_user else render_validation_error!(issue) @@ -202,17 +196,11 @@ module API render_api_error!({ labels: errors }, 400) end + attrs[:labels] = params[:labels] if params[:labels] + issue = ::Issues::UpdateService.new(user_project, current_user, attrs).execute(issue) if issue.valid? - # Find or create labels and attach to issue. Labels are valid because - # we already checked its name, so there can't be an error here - if params[:labels] && can?(current_user, :admin_issue, user_project) - issue.remove_labels - # Create and add labels to the new created issue - issue.add_labels_by_names(params[:labels].split(',')) - end - present issue, with: Entities::Issue, current_user: current_user else render_validation_error!(issue) |