diff options
Diffstat (limited to 'api4/team.go')
-rw-r--r-- | api4/team.go | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/api4/team.go b/api4/team.go index 8564029b0..d1db268dc 100644 --- a/api4/team.go +++ b/api4/team.go @@ -19,9 +19,9 @@ func InitTeam() { BaseRoutes.TeamsForUser.Handle("", ApiSessionRequired(getTeamsForUser)).Methods("GET") BaseRoutes.Team.Handle("", ApiSessionRequired(getTeam)).Methods("GET") + BaseRoutes.Team.Handle("/stats", ApiHandler(getTeamStats)).Methods("GET") BaseRoutes.TeamMember.Handle("", ApiSessionRequired(getTeamMember)).Methods("GET") - } func createTeam(c *Context, w http.ResponseWriter, r *http.Request) { @@ -104,3 +104,23 @@ func getTeamMember(c *Context, w http.ResponseWriter, r *http.Request) { return } } + +func getTeamStats(c *Context, w http.ResponseWriter, r *http.Request) { + c.RequireTeamId() + if c.Err != nil { + return + } + + if !app.SessionHasPermissionToTeam(c.Session, c.Params.TeamId, model.PERMISSION_VIEW_TEAM) { + c.SetPermissionError(model.PERMISSION_VIEW_TEAM) + return + } + + if stats, err := app.GetTeamStats(c.Params.TeamId); err != nil { + c.Err = err + return + } else { + w.Write([]byte(stats.ToJson())) + return + } +} |