error instead of panic if cloud endpoints are hit (#22211)

* error instead of panic when team edition receives a request to check on CWS availability.
Этот коммит содержится в:
Nathaniel Allred
2023-02-01 14:11:00 -06:00
коммит произвёл GitHub
родитель f2d151cfd5
Коммит 6bca1f22e6
4 изменённых файлов: 60 добавлений и 1 удалений

Просмотреть файл

@@ -755,7 +755,12 @@ func handleCWSWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
}
func handleCheckCWSConnection(c *Context, w http.ResponseWriter, r *http.Request) {
if err := c.App.Cloud().CheckCWSConnection(c.AppContext.Session().UserId); err != nil {
cloud := c.App.Cloud()
if cloud == nil {
c.Err = model.NewAppError("Api4.handleCWSHealthCheck", "api.server.cws.needs_enterprise_edition", nil, "", http.StatusBadRequest)
return
}
if err := cloud.CheckCWSConnection(c.AppContext.Session().UserId); err != nil {
c.Err = model.NewAppError("Api4.handleCWSHealthCheck", "api.server.cws.health_check.app_error", nil, "CWS Server is not available.", http.StatusInternalServerError)
return
}