func updateValetFeature(c *Context, w http.ResponseWriter, r *http.Request) { props := model.MapFromJson(r.Body) allowValetStr := props["allow_valet"] if len(allowValetStr) == 0 { c.SetInvalidParam("updateValetFeature", "allow_valet") return } allowValet := allowValetStr == "true" teamId := props["team_id"] if len(teamId) > 0 && len(teamId) != 26 { c.SetInvalidParam("updateValetFeature", "team_id") return } else if len(teamId) == 0 { teamId = c.Session.TeamId } tchan := Srv.Store.Team().Get(teamId) if !c.HasPermissionsToTeam(teamId, "updateValetFeature") { return } if !model.IsInRole(c.Session.Roles, model.ROLE_TEAM_ADMIN) { c.Err = model.NewAppError("updateValetFeature", "You do not have the appropriate permissions", "userId="+c.Session.UserId) c.Err.StatusCode = http.StatusForbidden return } var team *model.Team if tResult := <-tchan; tResult.Err != nil { c.Err = tResult.Err return } else { team = tResult.Data.(*model.Team) } team.AllowValet = allowValet if result := <-Srv.Store.Team().Update(team); result.Err != nil { c.Err = result.Err return } w.Write([]byte(model.MapToJson(props))) }