Add GET /teams/invite/{invite_id} endpoint for v4 (#6685)
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
effaeee830
Коммит
2e6fd031d1
25
api4/team.go
25
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)))
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user