Removed post limit warning banner (#27036)
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
cef7826fa8
Коммит
13d9a9b6cc
@@ -14,8 +14,6 @@ import (
|
||||
const (
|
||||
maxUsersLimit = 10_000
|
||||
maxUsersHardLimit = 11_000
|
||||
|
||||
maxPostLimit = 5_000_000
|
||||
)
|
||||
|
||||
func (a *App) GetServerLimits() (*model.ServerLimits, *model.AppError) {
|
||||
@@ -33,17 +31,6 @@ func (a *App) GetServerLimits() (*model.ServerLimits, *model.AppError) {
|
||||
limits.MaxUsersHardLimit = maxUsersHardLimit
|
||||
}
|
||||
|
||||
if a.shouldShowPostLimits() {
|
||||
postCount, appErr := a.Srv().Store().Post().AnalyticsPostCount(&model.PostCountOptions{ExcludeDeleted: true})
|
||||
if appErr != nil {
|
||||
mlog.Error("Failed to get post count from database", mlog.String("error", appErr.Error()))
|
||||
return nil, model.NewAppError("GetServerLimits", "app.limits.get_server_limits.post_count.store_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
|
||||
}
|
||||
|
||||
limits.MaxPostLimit = maxPostLimit
|
||||
limits.PostCount = postCount
|
||||
}
|
||||
|
||||
return limits, nil
|
||||
}
|
||||
|
||||
@@ -55,14 +42,6 @@ func (a *App) shouldShowUserLimits() bool {
|
||||
return a.License() == nil
|
||||
}
|
||||
|
||||
func (a *App) shouldShowPostLimits() bool {
|
||||
if maxPostLimit == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
return a.License() == nil
|
||||
}
|
||||
|
||||
func (a *App) isHardUserLimitExceeded() (bool, *model.AppError) {
|
||||
userLimits, appErr := a.GetServerLimits()
|
||||
if appErr != nil {
|
||||
|
||||
@@ -6,8 +6,6 @@ package app
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -23,10 +21,6 @@ func TestGetServerLimits(t *testing.T) {
|
||||
// InitBasic creates 3 users by default
|
||||
require.Equal(t, int64(3), serverLimits.ActiveUserCount)
|
||||
require.Equal(t, int64(10000), serverLimits.MaxUsersLimit)
|
||||
|
||||
// 5 posts are created by default
|
||||
require.Equal(t, int64(5), serverLimits.PostCount)
|
||||
require.Equal(t, int64(5_000_000), serverLimits.MaxPostLimit)
|
||||
})
|
||||
|
||||
t.Run("user count should increase on creating new user and decrease on permanently deleting", func(t *testing.T) {
|
||||
@@ -153,30 +147,4 @@ func TestGetServerLimits(t *testing.T) {
|
||||
require.Equal(t, int64(0), serverLimits.ActiveUserCount)
|
||||
require.Equal(t, int64(0), serverLimits.MaxUsersLimit)
|
||||
})
|
||||
|
||||
t.Run("post count should increase on creating new post and should decrease on deleting post", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
serverLimits, appErr := th.App.GetServerLimits()
|
||||
require.Nil(t, appErr)
|
||||
require.Equal(t, int64(5), serverLimits.PostCount)
|
||||
|
||||
// now we create a new post
|
||||
team := th.CreateTeam()
|
||||
channel := th.CreateChannel(request.TestContext(t), team)
|
||||
post := th.CreatePost(channel)
|
||||
|
||||
serverLimits, appErr = th.App.GetServerLimits()
|
||||
require.Nil(t, appErr)
|
||||
require.Equal(t, int64(6), serverLimits.PostCount)
|
||||
|
||||
// now we'll delete the post
|
||||
_, appErr = th.App.DeletePost(request.TestContext(t), post.Id, "")
|
||||
require.Nil(t, appErr)
|
||||
|
||||
serverLimits, appErr = th.App.GetServerLimits()
|
||||
require.Nil(t, appErr)
|
||||
require.Equal(t, int64(5), serverLimits.PostCount)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2033,12 +2033,8 @@ func TestCreateUserOrGuest(t *testing.T) {
|
||||
mockUserStore := storemocks.UserStore{}
|
||||
mockUserStore.On("Count", mock.Anything).Return(int64(12000), nil)
|
||||
|
||||
mockPostStore := storemocks.PostStore{}
|
||||
mockPostStore.On("AnalyticsPostCount", mock.Anything).Return(int64(1000), nil)
|
||||
|
||||
mockStore := th.App.Srv().Store().(*storemocks.Store)
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
|
||||
user := &model.User{
|
||||
Email: "TestCreateUserOrGuest@example.com",
|
||||
@@ -2151,12 +2147,8 @@ func userCreationMocks(t *testing.T, th *TestHelper, userID string, activeUserCo
|
||||
mockProductNoticeStore := storemocks.ProductNoticesStore{}
|
||||
mockProductNoticeStore.On("View", userID, mock.Anything).Return(nil)
|
||||
|
||||
mockPostStore := storemocks.PostStore{}
|
||||
mockPostStore.On("AnalyticsPostCount", mock.Anything).Return(int64(1000), nil)
|
||||
|
||||
mockStore := th.App.Srv().Store().(*storemocks.Store)
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
mockStore.On("Post").Return(&mockPostStore)
|
||||
mockStore.On("Group").Return(&mockGroupStore)
|
||||
mockStore.On("Channel").Return(&mockChannelStore)
|
||||
mockStore.On("Preference").Return(&mockPreferencesStore)
|
||||
|
||||
@@ -5682,10 +5682,6 @@
|
||||
"id": "app.limits.get_app_limits.user_count.store_error",
|
||||
"translation": "Failed to get user count"
|
||||
},
|
||||
{
|
||||
"id": "app.limits.get_server_limits.post_count.store_error",
|
||||
"translation": "Failed to get post count"
|
||||
},
|
||||
{
|
||||
"id": "app.login.doLogin.updateLastLogin.error",
|
||||
"translation": "Could not update last login timestamp"
|
||||
|
||||
@@ -580,6 +580,26 @@ func (c *Client4) permissionsRoute() string {
|
||||
return "/permissions"
|
||||
}
|
||||
|
||||
func (c *Client4) limitsRoute() string {
|
||||
return "/limits"
|
||||
}
|
||||
|
||||
func (c *Client4) GetServerLimits(ctx context.Context) (*ServerLimits, *Response, error) {
|
||||
r, err := c.DoAPIGet(ctx, c.limitsRoute()+"/users", "")
|
||||
if err != nil {
|
||||
return nil, BuildResponse(r), err
|
||||
}
|
||||
defer closeBody(r)
|
||||
var serverLimits ServerLimits
|
||||
if r.StatusCode == http.StatusNotModified {
|
||||
return &serverLimits, BuildResponse(r), nil
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&serverLimits); err != nil {
|
||||
return nil, nil, NewAppError("GetServerLimits", "api.unmarshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
return &serverLimits, BuildResponse(r), nil
|
||||
}
|
||||
|
||||
func (c *Client4) bookmarksRoute(channelId string) string {
|
||||
return c.channelRoute(channelId) + "/bookmarks"
|
||||
}
|
||||
|
||||
@@ -7,7 +7,4 @@ type ServerLimits struct {
|
||||
MaxUsersLimit int64 `json:"maxUsersLimit"` // soft limit for max number of users.
|
||||
MaxUsersHardLimit int64 `json:"maxUsersHardLimit"` // hard limit for max number of active users.
|
||||
ActiveUserCount int64 `json:"activeUserCount"` // actual number of active users on server. Active = non deleted
|
||||
|
||||
MaxPostLimit int64 `json:"maxPostLimit"` // soft limit for max number of posts
|
||||
PostCount int64 `json:"postCount"` // actual number of posts in system.
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user