summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authortiagonbotelho <tiagonbotelho@hotmail.com>2016-08-08 17:25:39 +0100
committertiagonbotelho <tiagonbotelho@hotmail.com>2016-08-30 18:37:21 +0100
commit7532c012c26fc116f7c39f7c88ac3b08d818955c (patch)
treee136b2e0478fc56133d972ec354019b94c4872b7 /lib/api
parent0357df0c12f3c8ee157cd757da3e3585904ce857 (diff)
downloadgitlab-ce-7532c012c26fc116f7c39f7c88ac3b08d818955c.tar.gz
user is now notified when creating an issue through the api
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/issues.rb18
1 files changed, 16 insertions, 2 deletions
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