diff options
Diffstat (limited to 'lib/mattermost/team.rb')
-rw-r--r-- | lib/mattermost/team.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/mattermost/team.rb b/lib/mattermost/team.rb index 06e57a21e2e..54d029cb022 100644 --- a/lib/mattermost/team.rb +++ b/lib/mattermost/team.rb @@ -1,10 +1,17 @@ module Mattermost class Team < Session - # After normalization this returns an array of hashes - # - # [{"id"=>"paf573pj9t81urupw3fanozeda", "display_name"=>"my team", <snip>}] - def self.all - get('/api/v3/teams/all').parsed_response.values + def self.team_admin + body = get('/users/initial_load').parsed_response + + return [] unless body['team_members'] + + team_ids = body['team_members'].map do |team| + team['team_id'] if team['roles'].split.include?('team_admin') + end.compact + + body['teams'].select do |team| + team_ids.include?(team['id']) + end end end end |