summaryrefslogtreecommitdiff
path: root/lib/mattermost/team.rb
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2016-12-15 20:19:42 +0100
committerZ.J. van de Weg <git@zjvandeweg.nl>2016-12-16 12:31:51 +0100
commit0045996728308bcb7643618ab48efb7e04e7d4bf (patch)
tree91041209a3f78164afb0598f82ec9fc14667f968 /lib/mattermost/team.rb
parent99d8d6f0d48e28f5ba798d1d4461071a01435054 (diff)
downloadgitlab-ce-0045996728308bcb7643618ab48efb7e04e7d4bf.tar.gz
Add auto configure of commands
Diffstat (limited to 'lib/mattermost/team.rb')
-rw-r--r--lib/mattermost/team.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/mattermost/team.rb b/lib/mattermost/team.rb
index 76e238a866e..54d029cb022 100644
--- a/lib/mattermost/team.rb
+++ b/lib/mattermost/team.rb
@@ -1,10 +1,17 @@
module Mattermost
- class Team < Mattermost
- # After normalization this returns an array of hashes
- #
- # [{"id"=>"paf573pj9t81urupw3fanozeda", "display_name"=>"my team", <snip>}]
- def self.all
- @all_teams ||= get('/teams/all').parsed_response.values
+ class Team < Session
+ 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