diff options
author | Valery Sizov <valery@gitlab.com> | 2017-05-04 15:11:15 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2017-05-04 17:11:53 +0300 |
commit | 387c4b2c21a44360386a9b8ce6849e7f1b8a3de9 (patch) | |
tree | 446b8338efe8ad22ca03b00b2dc72b22c4174e02 /app/services/slash_commands/interpret_service.rb | |
parent | 68c12e15cc236548918f91393ebef3c06c124814 (diff) |
Backport of multiple_assignees_feature [ci skip]
Diffstat (limited to 'app/services/slash_commands/interpret_service.rb')
-rw-r--r-- | app/services/slash_commands/interpret_service.rb | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/app/services/slash_commands/interpret_service.rb b/app/services/slash_commands/interpret_service.rb index 6aeebc26685..dc2ee695384 100644 --- a/app/services/slash_commands/interpret_service.rb +++ b/app/services/slash_commands/interpret_service.rb @@ -88,20 +88,33 @@ module SlashCommands current_user.can?(:"admin_#{issuable.to_ability_name}", project) end command :assign do |assignee_param| - user = extract_references(assignee_param, :user).first - user ||= User.find_by(username: assignee_param) + user_ids = extract_references(assignee_param, :user).map(&:id) - @updates[:assignee_id] = user.id if user + if user_ids.empty? + user_ids = User.where(username: assignee_param.split(' ').map(&:strip)).pluck(:id) + end + + next if user_ids.empty? + + if issuable.is_a?(Issue) + @updates[:assignee_ids] = user_ids + else + @updates[:assignee_id] = user_ids.last + end end desc 'Remove assignee' condition do issuable.persisted? && - issuable.assignee_id? && + issuable.assignees.any? && current_user.can?(:"admin_#{issuable.to_ability_name}", project) end command :unassign do - @updates[:assignee_id] = nil + if issuable.is_a?(Issue) + @updates[:assignee_ids] = [] + else + @updates[:assignee_id] = nil + end end desc 'Set milestone' |