summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2016-12-16 11:37:04 +0100
committerZ.J. van de Weg <git@zjvandeweg.nl>2016-12-16 11:37:04 +0100
commitbbeef3235b1d4255f73172447f252f6ee1325533 (patch)
tree01dcf6dad4002f098e9cdee79e6fec27d3adbfa3
parent80764241c78e8b5548fcf17fe07d5fbf8c7d1391 (diff)
downloadgitlab-ce-zj-command-failure.tar.gz
Update team methods [ci skip]zj-command-failure
-rw-r--r--lib/mattermost/command.rb9
-rw-r--r--lib/mattermost/team.rb17
2 files changed, 18 insertions, 8 deletions
diff --git a/lib/mattermost/command.rb b/lib/mattermost/command.rb
index 6a696201bee..b6446935eb6 100644
--- a/lib/mattermost/command.rb
+++ b/lib/mattermost/command.rb
@@ -1,7 +1,7 @@
module Mattermost
class Command < Session
def self.all(team_id)
- get("/api/v3/teams/#{team_id}/commands/list_team_commands")
+ get("/teams/#{team_id}/commands/list_team_commands").parsed_response
end
# params should be a hash, which supplies _at least_:
@@ -16,10 +16,13 @@ module Mattermost
description: 'Perform common operations on GitLab',
display_name: 'GitLab',
method: 'P',
- user_name: 'GitLab'
+ user_name: 'GitLab',
+ trigger: 'gitlab',
}.merge(params)
- post( "/api/v3/teams/#{team_id}/commands/create", command.to_json).parsed_response['token']
+ response = post( "/teams/#{team_id}/commands/create", body: command.to_json)
+
+ response.parsed_response['token']
end
end
end
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