From 2e6fd031d15a9502e7a7a4536febfe49780c0697 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Tue, 20 Jun 2017 09:55:43 -0400 Subject: Add GET /teams/invite/{invite_id} endpoint for v4 (#6685) --- api4/team.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'api4/team.go') 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))) + } +} -- cgit v1.2.3-1-g7c22