[MM-60684] GetMaxPostSize: update threshold to V2, it was way overdue (#28662)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1f7f0d20cd
Коммит
74afa1fa78
@@ -369,12 +369,7 @@ func (ps *PlatformService) IsFirstUserAccount() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ps *PlatformService) MaxPostSize() int {
|
func (ps *PlatformService) MaxPostSize() int {
|
||||||
maxPostSize := ps.Store.Post().GetMaxPostSize()
|
return ps.Store.Post().GetMaxPostSize()
|
||||||
if maxPostSize == 0 {
|
|
||||||
return model.PostMessageMaxRunesV1
|
|
||||||
}
|
|
||||||
|
|
||||||
return maxPostSize
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps *PlatformService) isUpgradedFromTE() bool {
|
func (ps *PlatformService) isUpgradedFromTE() bool {
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ import (
|
|||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
"github.com/mattermost/mattermost/server/public/plugin/plugintest/mock"
|
"github.com/mattermost/mattermost/server/public/plugin/plugintest/mock"
|
||||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/app/platform"
|
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/store/storetest"
|
|
||||||
storemocks "github.com/mattermost/mattermost/server/v8/channels/store/storetest/mocks"
|
storemocks "github.com/mattermost/mattermost/server/v8/channels/store/storetest/mocks"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/testlib"
|
"github.com/mattermost/mattermost/server/v8/channels/testlib"
|
||||||
eMocks "github.com/mattermost/mattermost/server/v8/einterfaces/mocks"
|
eMocks "github.com/mattermost/mattermost/server/v8/einterfaces/mocks"
|
||||||
@@ -731,53 +729,6 @@ func TestImageProxy(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMaxPostSize(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
testCases := []struct {
|
|
||||||
Description string
|
|
||||||
StoreMaxPostSize int
|
|
||||||
ExpectedMaxPostSize int
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
"Max post size less than model.model.POST_MESSAGE_MAX_RUNES_V1 ",
|
|
||||||
0,
|
|
||||||
model.PostMessageMaxRunesV1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"4000 rune limit",
|
|
||||||
4000,
|
|
||||||
4000,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"16383 rune limit",
|
|
||||||
16383,
|
|
||||||
16383,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
|
||||||
t.Run(testCase.Description, func(t *testing.T) {
|
|
||||||
mockStore := &storetest.Store{}
|
|
||||||
defer mockStore.AssertExpectations(t)
|
|
||||||
|
|
||||||
mockStore.PostStore.On("GetMaxPostSize").Return(testCase.StoreMaxPostSize)
|
|
||||||
|
|
||||||
app := App{
|
|
||||||
ch: &Channels{
|
|
||||||
srv: &Server{
|
|
||||||
platform: &platform.PlatformService{
|
|
||||||
Store: mockStore,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.Equal(t, testCase.ExpectedMaxPostSize, app.MaxPostSize())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeletePostWithFileAttachments(t *testing.T) {
|
func TestDeletePostWithFileAttachments(t *testing.T) {
|
||||||
th := Setup(t).InitBasic()
|
th := Setup(t).InitBasic()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|||||||
@@ -2619,17 +2619,14 @@ func (s *SqlPostStore) determineMaxPostSize() int {
|
|||||||
mlog.Warn("Unable to determine the maximum supported post size", mlog.Err(err))
|
mlog.Warn("Unable to determine the maximum supported post size", mlog.Err(err))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mlog.Warn("No implementation found to determine the maximum supported post size")
|
mlog.Error("No implementation found to determine the maximum supported post size")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assume a worst-case representation of four bytes per rune.
|
// Assume a worst-case representation of four bytes per rune.
|
||||||
maxPostSize := int(maxPostSizeBytes) / 4
|
maxPostSize := int(maxPostSizeBytes) / 4
|
||||||
|
|
||||||
// To maintain backwards compatibility, don't yield a maximum post
|
if maxPostSize < model.PostMessageMaxRunesV2 {
|
||||||
// size smaller than the previous limit, even though it wasn't
|
maxPostSize = model.PostMessageMaxRunesV2
|
||||||
// actually possible to store 4000 runes in all cases.
|
|
||||||
if maxPostSize < model.PostMessageMaxRunesV1 {
|
|
||||||
maxPostSize = model.PostMessageMaxRunesV1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mlog.Info("Post.Message has size restrictions", mlog.Int("max_characters", maxPostSize), mlog.Int("max_bytes", maxPostSizeBytes))
|
mlog.Info("Post.Message has size restrictions", mlog.Int("max_characters", maxPostSize), mlog.Int("max_bytes", maxPostSizeBytes))
|
||||||
|
|||||||
@@ -4314,8 +4314,7 @@ func testPostStoreGetOldest(t *testing.T, rctx request.CTX, ss store.Store) {
|
|||||||
assert.EqualValues(t, o2.Id, r1.Id)
|
assert.EqualValues(t, o2.Id, r1.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGetMaxPostSize(t *testing.T, rctx request.CTX, ss store.Store) {
|
func testGetMaxPostSize(t *testing.T, _ request.CTX, ss store.Store) {
|
||||||
assert.Equal(t, model.PostMessageMaxRunesV2, ss.Post().GetMaxPostSize())
|
|
||||||
assert.Equal(t, model.PostMessageMaxRunesV2, ss.Post().GetMaxPostSize())
|
assert.Equal(t, model.PostMessageMaxRunesV2, ss.Post().GetMaxPostSize())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user