diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-06-20 09:55:43 -0400 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2017-06-20 14:55:43 +0100 |
commit | 2e6fd031d15a9502e7a7a4536febfe49780c0697 (patch) | |
tree | 644ad924de6ac441eee9f941683a6f92859229b6 /api4/team.go | |
parent | effaeee830efa78cd15218f6ba3920031ff8a5c1 (diff) | |
download | chat-2e6fd031d15a9502e7a7a4536febfe49780c0697.tar.gz chat-2e6fd031d15a9502e7a7a4536febfe49780c0697.tar.bz2 chat-2e6fd031d15a9502e7a7a4536febfe49780c0697.zip |
Add GET /teams/invite/{invite_id} endpoint for v4 (#6685)
Diffstat (limited to 'api4/team.go')
-rw-r--r-- | api4/team.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/api4/team.go b/api4/team.go index 57a715937..00a16d5c1 100644 --- a/api4/team.go +++ b/api4/team.go @@ -49,6 +49,7 @@ func InitTeam() { BaseRoutes.Team.Handle("/import", ApiSessionRequired(importTeam)).Methods("POST") BaseRoutes.Team.Handle("/invite/email", ApiSessionRequired(inviteUsersToTeam)).Methods("POST") + BaseRoutes.Teams.Handle("/invite/{invite_id:[A-Za-z0-9]+}", ApiHandler(getInviteInfo)).Methods("GET") } func createTeam(c *Context, w http.ResponseWriter, r *http.Request) { @@ -687,3 +688,27 @@ func inviteUsersToTeam(c *Context, w http.ResponseWriter, r *http.Request) { ReturnStatusOK(w) } + +func getInviteInfo(c *Context, w http.ResponseWriter, r *http.Request) { + c.RequireInviteId() + if c.Err != nil { + return + } + + if team, err := app.GetTeamByInviteId(c.Params.InviteId); err != nil { + c.Err = err + return + } else { + if !(team.Type == model.TEAM_OPEN) { + c.Err = model.NewAppError("getInviteInfo", "api.team.get_invite_info.not_open_team", nil, "id="+c.Params.InviteId, http.StatusForbidden) + return + } + + result := map[string]string{} + result["display_name"] = team.DisplayName + result["description"] = team.Description + result["name"] = team.Name + result["id"] = team.Id + w.Write([]byte(model.MapToJson(result))) + } +} |