lib/slack/smart-bot/commands/general/teams/delete_team.rb in slack-smart-bot-1.14.2 vs lib/slack/smart-bot/commands/general/teams/delete_team.rb in slack-smart-bot-1.15.0
- old
+ new
@@ -17,22 +17,22 @@
if @teams[team_name.to_sym].channels.key?("members")
@teams[team_name.to_sym].channels["members"].each do |ch|
get_channels_name_and_id() unless @channels_id.key?(ch)
tm = get_channel_members(@channels_id[ch])
tm.each do |m|
- user_info = @users.select { |u| u.id == m or (u.key?(:enterprise_user) and u.enterprise_user.id == m) }[-1]
- team_members << user_info.name unless user_info.is_app_user or user_info.is_bot
+ user_info = find_user(m)
+ team_members << "#{user_info.team_id}_#{user_info.name}" unless user_info.nil? or user_info.is_app_user or user_info.is_bot
end
end
end
team_members.flatten!
team_members.uniq!
all_team_members += team_members
all_team_members.uniq!
end
if !@teams.key?(team_name.to_sym)
respond "It seems like the team *#{team_name}* doesn't exist.\nRelated commands `add team TEAM_NAME PROPERTIES`, `see team TEAM_NAME`, `see teams`"
- elsif !(all_team_members + [@teams[team_name.to_sym].creator] + config.masters).flatten.include?(user.name)
+ elsif !(all_team_members + [@teams[team_name.to_sym].creator] + config.team_id_masters).flatten.include?("#{user.team_id}_#{user.name}")
respond "You have to be a member of the team, the creator or a Master admin to be able to delete this team."
else
if answer.empty?
ask "do you really want to delete the #{team_name} team? (yes/no)"
else