Skip to content

Commit

Permalink
ユーザのカスタムフィールドにグループが含まれた場合に対応
Browse files Browse the repository at this point in the history
  • Loading branch information
tkusukawa committed Feb 3, 2019
1 parent 81395dd commit b42abe9
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions lib/custom_users_as_assignees/issue_patch.rb
Expand Up @@ -56,7 +56,26 @@ def custom_users
end
custom_user_ids = custom_user_values.map(&:value).flatten
custom_user_ids.reject! { |id| id.blank? }
User.find(custom_user_ids)
# User.find(custom_user_ids)
# Principal.find(custom_user_ids)
return users_from_ids(custom_user_ids)
end

def users_from_ids(ids)
users = []
ids.each do |id|
user = User.find_by_id(id)
if user
users << user
next
end
group = Group.find_by_id(id)
if group
users += users_from_ids(group.user_ids)
next
end
end
return users
end

# added or removed users selected in custom fields with type 'user'
Expand All @@ -76,7 +95,7 @@ def custom_users_added_or_removed
custom_user_added_ids.uniq!
custom_user_removed_ids.uniq!
custom_user_changed_ids = (custom_user_added_ids + custom_user_removed_ids).uniq
User.find(custom_user_changed_ids)
Principal.find(custom_user_changed_ids)
else
[]
end
Expand Down

0 comments on commit b42abe9

Please sign in to comment.