Этот коммит содержится в:
Conor Macpherson
2022-12-29 14:58:05 -05:00
родитель 46c28e4257
Коммит 6685268085
5 изменённых файлов: 43 добавлений и 0 удалений

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

@@ -52,6 +52,9 @@ func (api *API) InitCloud() {
// POST /api/v4/cloud/webhook
api.BaseRoutes.Cloud.Handle("/webhook", api.CloudAPIKeyRequired(handleCWSWebhook)).Methods("POST")
// GET /api/v4/cloud/cws-health-check
api.BaseRoutes.Cloud.Handle("/check-cws-connection", api.APIHandler(handleCheckCWSConnection)).Methods("GET")
}
func getSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -746,3 +749,12 @@ func handleCWSWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
ReturnStatusOK(w)
}
func handleCheckCWSConnection(c *Context, w http.ResponseWriter, r *http.Request) {
if err := c.App.Cloud().CheckCWSConnection(); err != nil {
c.Err = model.NewAppError("Api4.handleCWSHealthCheck", "api.server.cws.health_check.app_error", nil, "CWS Server is not available.", http.StatusInternalServerError)
return
}
ReturnStatusOK(w)
}

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

@@ -45,4 +45,6 @@ type CloudInterface interface {
CreateOrUpdateSubscriptionHistoryEvent(userID string, userCount int) (*model.SubscriptionHistory, error)
HandleLicenseChange() error
CheckCWSConnection() error
}

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

@@ -60,6 +60,20 @@ func (_m *CloudInterface) ChangeSubscription(userID string, subscriptionID strin
return r0, r1
}
// CheckCWSConnection provides a mock function with given fields:
func (_m *CloudInterface) CheckCWSConnection() error {
ret := _m.Called()
var r0 error
if rf, ok := ret.Get(0).(func() error); ok {
r0 = rf()
} else {
r0 = ret.Error(0)
}
return r0
}
// ConfirmCustomerPayment provides a mock function with given fields: userID, confirmRequest
func (_m *CloudInterface) ConfirmCustomerPayment(userID string, confirmRequest *model.ConfirmPaymentMethodRequest) error {
ret := _m.Called(userID, confirmRequest)

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

@@ -2575,6 +2575,10 @@
"id": "api.scheme.patch_scheme.license.error",
"translation": "Your license does not support update permissions schemes"
},
{
"id": "api.server.cws.health_check.app_error",
"translation": "CWS Server is not available."
},
{
"id": "api.server.hosted_signup_unavailable.error",
"translation": "Portal unavailable for self-hosted signup."

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

@@ -8700,6 +8700,17 @@ func (c *Client4) AddUserToGroupSyncables(userID string) (*Response, error) {
return BuildResponse(r), nil
}
func (c *Client4) CheckCWSConnection() (*Response, error) {
r, err := c.DoAPIGet(c.cloudRoute()+"/healthz", "")
if err != nil {
return BuildResponse(r), err
}
defer closeBody(r)
return BuildResponse(r), nil
}
// Worktemplates sections
func (c *Client4) worktemplatesRoute() string {