summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortiagonbotelho <tiagonbotelho@hotmail.com>2016-08-08 17:25:39 +0100
committertiagonbotelho <tiagonbotelho@hotmail.com>2016-08-26 13:38:57 +0100
commita89e6bbf4b48865d0caf455e2428786fcfe12dc0 (patch)
tree5e96ada533e12e8876a4d92bd984cf450bdcf29e
parent1bf2fe276ff084d3b2e0860710ec115a317dd9fc (diff)
downloadgitlab-ce-a89e6bbf4b48865d0caf455e2428786fcfe12dc0.tar.gz
user is now notified when creating an issue through the api
-rw-r--r--CHANGELOG1
-rw-r--r--lib/api/issues.rb18
2 files changed, 17 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index df8dec7bdde..e345a6f7da3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -55,6 +55,7 @@ v 8.11.0
- Remove the http_parser.rb dependency by removing the tinder gem. !5758 (tbalthazar)
- Add Koding (online IDE) integration
- Ability to specify branches for Pivotal Tracker integration (Egor Lynko)
+ - Creating an issue through our API now emails label subscribers !5720
- Fix don't pass a local variable called `i` to a partial. !20510 (herminiotorres)
- Fix rename `add_users_into_project` and `projects_ids`. !20512 (herminiotorres)
- Fix adding line comments on the initial commit to a repo !5900
diff --git a/lib/api/issues.rb b/lib/api/issues.rb
index 077258faee1..1121285f0af 100644
--- a/lib/api/issues.rb
+++ b/lib/api/issues.rb
@@ -154,6 +154,20 @@ module API
render_api_error!({ labels: errors }, 400)
end
+ if params[:labels].present?
+ params[:labels] = params[:labels].split(",").each { |word| word.strip! }
+ attrs[:label_ids] = []
+
+ params[:labels].each do |label|
+ existing_label = user_project.labels.where(title: label).first
+
+ unless existing_label.nil?
+ attrs[:label_ids] << existing_label.id
+ params[:labels].delete(label)
+ end
+ end
+ end
+
project = user_project
issue = ::Issues::CreateService.new(project, current_user, attrs.merge(request: request, api: true)).execute
@@ -163,10 +177,10 @@ module API
end
if issue.valid?
- # Find or create labels and attach to issue. Labels are valid because
+ # create new 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(','))
+ issue.add_labels_by_names(params[:labels])
end
present issue, with: Entities::Issue, current_user: current_user