[MM-36198] - Activating a user in System Console does not respect cloud user limits (#17719)
* [MM-36198] - Activating a user in System Console does not respect cloud user limits * feedback impl * improve error check
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a2700684f1
Коммит
5ce5ea93f4
@@ -113,31 +113,13 @@ func changeSubscription(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func getSubscriptionStats(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if c.App.Srv().License() == nil || !*c.App.Srv().License().Features.Cloud {
|
||||
c.Err = model.NewAppError("Api4.getSubscriptionStats", "api.cloud.license_error", nil, "", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
subscription, appErr := c.App.Cloud().GetSubscription("")
|
||||
|
||||
if appErr != nil {
|
||||
c.Err = model.NewAppError("Api4.getSubscriptionStats", "api.cloud.request_error", nil, appErr.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
count, err := c.App.Srv().Store.User().Count(model.UserCountOptions{})
|
||||
s, err := c.App.GetSubscriptionStats()
|
||||
if err != nil {
|
||||
c.Err = model.NewAppError("Api4.getSubscriptionStats", "app.user.get_total_users_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
cloudUserLimit := *c.App.Config().ExperimentalSettings.CloudUserLimit
|
||||
|
||||
s := cloudUserLimit - count
|
||||
|
||||
stats, _ := json.Marshal(model.SubscriptionStats{
|
||||
RemainingSeats: int(s),
|
||||
IsPaidTier: subscription.IsPaidTier,
|
||||
})
|
||||
stats, _ := json.Marshal(s)
|
||||
|
||||
w.Write([]byte(string(stats)))
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user