Added API to return user count bands and user count (#25796)

Этот коммит содержится в:
Harshil Sharma
2023-12-21 18:30:19 +05:30
коммит произвёл GitHub
родитель cac50f593b
Коммит a59f5ccded
13 изменённых файлов: 329 добавлений и 0 удалений

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

@@ -567,6 +567,10 @@ func (c *Client4) permissionsRoute() string {
return "/permissions"
}
func (c *Client4) limitsRoute() string {
return "/limits"
}
func (c *Client4) DoAPIGet(ctx context.Context, url string, etag string) (*http.Response, error) {
return c.DoAPIRequest(ctx, http.MethodGet, c.APIURL+url, "", etag)
}
@@ -8795,3 +8799,19 @@ func (c *Client4) SubmitTrueUpReview(ctx context.Context, req map[string]any) (*
return BuildResponse(r), nil
}
func (c *Client4) GetUserLimits(ctx context.Context) (*UserLimits, *Response, error) {
r, err := c.DoAPIGet(ctx, c.limitsRoute()+"/users", "")
if err != nil {
return nil, BuildResponse(r), err
}
defer closeBody(r)
var userLimits UserLimits
if r.StatusCode == http.StatusNotModified {
return &userLimits, BuildResponse(r), nil
}
if err := json.NewDecoder(r.Body).Decode(&userLimits); err != nil {
return nil, nil, NewAppError("GetUserLimits", "api.unmarshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
}
return &userLimits, BuildResponse(r), nil
}

11
server/public/model/limits.go Обычный файл
Просмотреть файл

@@ -0,0 +1,11 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package model
type UserLimits struct {
MaxUsersLimit int64 `json:"maxUsersLimit"` // max number of users allowed
LowerBandUserLimit int64 `json:"lowerBandUserLimit"` // user count for 1st warning
UpperBandUserLimit int64 `json:"upperBandUserLimit"` // user count for 2nd warning
ActiveUserCount int64 `json:"activeUserCount"` // actual number of active users on server. Active = non deleted
}