Added API to return user count bands and user count (#25796)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
cac50f593b
Коммит
a59f5ccded
@@ -141,6 +141,8 @@ type Routes struct {
|
||||
IPFiltering *mux.Router // 'api/v4/ip_filtering'
|
||||
|
||||
Reports *mux.Router // 'api/v4/reports'
|
||||
|
||||
Limits *mux.Router // 'api/v4/limits'
|
||||
}
|
||||
|
||||
type API struct {
|
||||
@@ -269,6 +271,8 @@ func Init(srv *app.Server) (*API, error) {
|
||||
|
||||
api.BaseRoutes.Reports = api.BaseRoutes.APIRoot.PathPrefix("/reports").Subrouter()
|
||||
|
||||
api.BaseRoutes.Limits = api.BaseRoutes.APIRoot.PathPrefix("/limits").Subrouter()
|
||||
|
||||
api.InitUser()
|
||||
api.InitBot()
|
||||
api.InitTeam()
|
||||
@@ -314,6 +318,7 @@ func Init(srv *app.Server) (*API, error) {
|
||||
api.InitDrafts()
|
||||
api.InitIPFiltering()
|
||||
api.InitReports()
|
||||
api.InitLimits()
|
||||
|
||||
srv.Router.Handle("/api/v4/{anything:.*}", http.HandlerFunc(api.Handle404))
|
||||
|
||||
|
||||
34
server/channels/api4/limits.go
Обычный файл
34
server/channels/api4/limits.go
Обычный файл
@@ -0,0 +1,34 @@
|
||||
// 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("/users", api.APISessionRequired(getUserLimits)).Methods("GET")
|
||||
}
|
||||
|
||||
func getUserLimits(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if !(c.IsSystemAdmin() && c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionSysconsoleReadUserManagementUsers)) {
|
||||
c.SetPermissionError(model.PermissionSysconsoleReadUserManagementUsers)
|
||||
return
|
||||
}
|
||||
|
||||
userLimits, err := c.App.GetUserLimits()
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
if err := json.NewEncoder(w).Encode(userLimits); err != nil {
|
||||
c.Logger.Error("Error writing user limits response", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user