Add nil checks for cloud in case of air-gapped instances?

Этот коммит содержится в:
Conor Macpherson
2022-12-20 09:42:01 -05:00
родитель 9c4ce9016f
Коммит 6864717504

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

@@ -307,23 +307,21 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) {
return return
} }
if c.App.Cloud() == nil {
c.Err = model.NewAppError("requestRenewalLink", "api.license.upgrade_needed.app_error", nil, "", http.StatusForbidden)
return
}
license := c.App.Channels().License() license := c.App.Channels().License()
if license == nil { if license == nil {
http.Error(w, "A License is required to perform a true-up review", http.StatusBadRequest) http.Error(w, "A License is required to perform a true-up review", http.StatusBadRequest)
return return
} }
// Subscription Data var subscription *model.Subscription
userId := c.AppContext.Session().UserId if c.App.Cloud() != nil {
subscription, err := c.App.Cloud().GetSubscription(userId) // Subscription Data
if err != nil || subscription == nil { userId := c.AppContext.Session().UserId
http.Error(w, err.Error(), http.StatusInternalServerError) subscription, err := c.App.Cloud().GetSubscription(userId)
return if err != nil || subscription == nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
} }
// Customer Info & Usage Analytics // Customer Info & Usage Analytics
@@ -385,12 +383,16 @@ func requestTrueUpReview(c *Context, w http.ResponseWriter, r *http.Request) {
} }
} }
seats := 0
if subscription != nil {
seats = subscription.Seats
}
reviewProfile := model.TrueUpReviewProfile{ reviewProfile := model.TrueUpReviewProfile{
ServerId: c.App.TelemetryId(), ServerId: c.App.TelemetryId(),
ServerVersion: model.CurrentVersion, ServerVersion: model.CurrentVersion,
ServerInstallationType: os.Getenv(telemetry.EnvVarInstallType), ServerInstallationType: os.Getenv(telemetry.EnvVarInstallType),
LicenseId: license.Id, LicenseId: license.Id,
LicensedSeats: subscription.Seats, LicensedSeats: seats,
LicensePlan: license.SkuName, LicensePlan: license.SkuName,
CustomerName: license.Customer.Name, CustomerName: license.Customer.Name,
ActiveUsers: activeUserCount, ActiveUsers: activeUserCount,