summaryrefslogtreecommitdiffstats
path: root/api4/team.go
diff options
context:
space:
mode:
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 {