Commit 7532c012 authored by tiagonbotelho's avatar tiagonbotelho

user is now notified when creating an issue through the api

parent 0357df0c
......@@ -70,6 +70,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
......
......@@ -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
......
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