mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-03 20:40:00 -05:00
* Support for Entry license with limits + updates to Edition & License screen * Refactor message history limit to use entry sku limits * Fixed missing update on license change * Fix typo in limit types * Revert unnecessary thread change * Revert merge issue * Cleanup * Fix CTAs of limit notifications * Linting * More linting * Linting and fix tests * More linting * Fix tests * PR feedback and fix tests * Fix tests * Fix test * Fix test * Linting * Simplified Limit panels * Linting * PR feedback * Revert back job time * Linting * linting * Fixed issue switching in RHS * PR Feedback --------- Co-authored-by: Nick Misasi <nick.misasi@mattermost.com> Co-authored-by: Mattermost Build <build@mattermost.com>
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package api4
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
|
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
|
)
|
|
|
|
func (api *API) InitLimits() {
|
|
api.BaseRoutes.Limits.Handle("/server", api.APISessionRequired(getServerLimits)).Methods(http.MethodGet)
|
|
}
|
|
|
|
func getServerLimits(c *Context, w http.ResponseWriter, r *http.Request) {
|
|
isAdmin := c.IsSystemAdmin() && c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionSysconsoleReadUserManagementUsers)
|
|
|
|
serverLimits, err := c.App.GetServerLimits()
|
|
if err != nil {
|
|
c.Err = err
|
|
return
|
|
}
|
|
|
|
// Non-admin users only get message history limit information, no user count data
|
|
if !isAdmin {
|
|
limitedData := &model.ServerLimits{
|
|
MaxUsersLimit: 0,
|
|
MaxUsersHardLimit: 0,
|
|
ActiveUserCount: 0,
|
|
LastAccessiblePostTime: serverLimits.LastAccessiblePostTime,
|
|
PostHistoryLimit: serverLimits.PostHistoryLimit,
|
|
}
|
|
serverLimits = limitedData
|
|
}
|
|
|
|
if err := json.NewEncoder(w).Encode(serverLimits); err != nil {
|
|
c.Logger.Warn("Error writing server limits response", mlog.Err(err))
|
|
}
|
|
}
|