diff options
Diffstat (limited to 'lib/mattermost/team.rb')
-rw-r--r-- | lib/mattermost/team.rb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/mattermost/team.rb b/lib/mattermost/team.rb index 714748aea3c..9e1b22623a3 100644 --- a/lib/mattermost/team.rb +++ b/lib/mattermost/team.rb @@ -1,21 +1,20 @@ module Mattermost - class Team < Session - def self.team_admin - return [] unless initial_load['team_members'] + class Team + def self.team_admin(session) + response_body = initial_load(session) + return [] unless response_body['team_members'] - team_ids = initial_load['team_members'].map do |team| + team_ids = response_body['team_members'].map do |team| team['team_id'] if team['roles'].split.include?('team_admin') end.compact - initial_load['teams'].select do |team| + response_body['teams'].select do |team| team_ids.include?(team['id']) end end - private - - def initial_load - @initial_load ||= get('/users/initial_load').parsed_response + def self.initial_load(session) + session.get('/api/v3/users/initial_load').parsed_response end end end |