summaryrefslogtreecommitdiffstats
path: root/api4/team.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-02-21 01:27:57 +0900
committerenahum <nahumhbl@gmail.com>2017-02-20 13:27:57 -0300
commit623560481b4bce2b87f19765455a461c7a504e31 (patch)
treee05071527ce330275f961928948d8ad291fd55a6 /api4/team.go
parent22118fafc8650214a3de13cf0cfa5a698b0e9a4a (diff)
downloadchat-623560481b4bce2b87f19765455a461c7a504e31.tar.gz
chat-623560481b4bce2b87f19765455a461c7a504e31.tar.bz2
chat-623560481b4bce2b87f19765455a461c7a504e31.zip
Implementation endpoint for APIv4: GET /teams/name/{name} (#5473)
* APIv4: GET /teams/name/{name} Signed-off-by: Saturnino Abril <saturnino.abril@gmail.com> * reorganized test with SystemAdminClient Signed-off-by: Saturnino Abril <saturnino.abril@gmail.com>
Diffstat (limited to 'api4/team.go')
-rw-r--r--api4/team.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/api4/team.go b/api4/team.go
index d1db268dc..2e3b6b982 100644
--- a/api4/team.go
+++ b/api4/team.go
@@ -21,6 +21,7 @@ func InitTeam() {
BaseRoutes.Team.Handle("", ApiSessionRequired(getTeam)).Methods("GET")
BaseRoutes.Team.Handle("/stats", ApiHandler(getTeamStats)).Methods("GET")
+ BaseRoutes.TeamByName.Handle("", ApiSessionRequired(getTeamByName)).Methods("GET")
BaseRoutes.TeamMember.Handle("", ApiSessionRequired(getTeamMember)).Methods("GET")
}
@@ -66,6 +67,21 @@ func getTeam(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
+func getTeamByName(c *Context, w http.ResponseWriter, r *http.Request) {
+ if team, err := app.GetTeamByName(c.Params.TeamName); err != nil {
+ c.Err = err
+ return
+ } else {
+ if team.Type != model.TEAM_OPEN && !app.SessionHasPermissionToTeam(c.Session, team.Id, model.PERMISSION_VIEW_TEAM) {
+ c.SetPermissionError(model.PERMISSION_VIEW_TEAM)
+ return
+ }
+
+ w.Write([]byte(team.ToJson()))
+ return
+ }
+}
+
func getTeamsForUser(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireUserId()
if c.Err != nil {