mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* MM-9661: rename POST_MESSAGE_MAX_RUNES to \0_v1 * MM-9661: s/4000/POST_MESSAGE_MAX_RUNES_V1/ in tests * MM-9661: introduce POST_MESSAGE_MAX_RUNES_V2 * MM-9661: migrate Postgres Posts.Message column to TEXT from VARCHAR(4000) This is safe to do in a production instance since the underyling type is not changing. We explicitly don't do this automatically for MySQL, but also don't need to since the ORM would have already created a TEXT column for MySQL in that case. * MM-9661: emit MaxPostSize in client config This value remains unconfigurable at this time, but exposes the current limit to the client. The limit remains at 4k in this commit. * MM-9661: introduce and use SqlPostStore.GetMaxPostSize Enforce a byte limitation in the database, and use 1/4 of that value as the rune count limitation (assuming a worst case UTF-8 representation). * move maxPostSizeCached, lastPostsCache and lastPostTimeCache out of the global context and onto the SqlPostStore * address feedback from code review: * ensure sqlstore unit tests are actually being run * move global caches into SqlPostStore * leverage sync.Once to address a race condition * modify upgrade semantics to match new db semantics gorp's behaviour on creating columns with a maximum length on Postgres differs from MySQL: * Postgres * gorp uses TEXT for string columns without a maximum length * gorp uses VARCHAR(N) for string columns with a maximum length of N * MySQL * gorp uses TEXT for string columns with a maximum length >= 256 * gorp uses VARCHAR(N) for string columns with a maximum length of N * gorp defaults to a maximum length of 255, implying VARCHAR(255) So the Message column has been TEXT on MySQL but VARCHAR(4000) on Postgres. With the new, longer limits of 65535, and without changes to gorp, the expected behaviour is TEXT on MySQL and VARCHAR(65535) on Postgres. This commit makes the upgrade semantics match the new database semantics. Ideally, we'd revisit the gorp behaviour at a later time. * allow TestMaxPostSize test cases to actually run in parallel * default maxPostSizeCached to POST_MESSAGE_MAX_RUNES_V1 in case the once initializer panics * fix casting error * MM-9661: skip the schema migration for Postgres It turns out resizing VARCHAR requires a rewrite in some versions of Postgres, but migrating VARCHAR to TEXT does not. Given the increasing complexity, let's defer the migration to the enduser instead.
440 lines
12 KiB
Go
440 lines
12 KiB
Go
// Code generated by mockery v1.0.0
|
|
|
|
// Regenerate this file using `make store-mocks`.
|
|
|
|
package mocks
|
|
|
|
import mock "github.com/stretchr/testify/mock"
|
|
import model "github.com/mattermost/mattermost-server/model"
|
|
import store "github.com/mattermost/mattermost-server/store"
|
|
|
|
// PostStore is an autogenerated mock type for the PostStore type
|
|
type PostStore struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// AnalyticsPostCount provides a mock function with given fields: teamId, mustHaveFile, mustHaveHashtag
|
|
func (_m *PostStore) AnalyticsPostCount(teamId string, mustHaveFile bool, mustHaveHashtag bool) store.StoreChannel {
|
|
ret := _m.Called(teamId, mustHaveFile, mustHaveHashtag)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string, bool, bool) store.StoreChannel); ok {
|
|
r0 = rf(teamId, mustHaveFile, mustHaveHashtag)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// AnalyticsPostCountsByDay provides a mock function with given fields: teamId
|
|
func (_m *PostStore) AnalyticsPostCountsByDay(teamId string) store.StoreChannel {
|
|
ret := _m.Called(teamId)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
|
r0 = rf(teamId)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// AnalyticsUserCountsWithPostsByDay provides a mock function with given fields: teamId
|
|
func (_m *PostStore) AnalyticsUserCountsWithPostsByDay(teamId string) store.StoreChannel {
|
|
ret := _m.Called(teamId)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
|
r0 = rf(teamId)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// ClearCaches provides a mock function with given fields:
|
|
func (_m *PostStore) ClearCaches() {
|
|
_m.Called()
|
|
}
|
|
|
|
// Delete provides a mock function with given fields: postId, time
|
|
func (_m *PostStore) Delete(postId string, time int64) store.StoreChannel {
|
|
ret := _m.Called(postId, time)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok {
|
|
r0 = rf(postId, time)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// Get provides a mock function with given fields: id
|
|
func (_m *PostStore) Get(id string) store.StoreChannel {
|
|
ret := _m.Called(id)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
|
r0 = rf(id)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetEtag provides a mock function with given fields: channelId, allowFromCache
|
|
func (_m *PostStore) GetEtag(channelId string, allowFromCache bool) store.StoreChannel {
|
|
ret := _m.Called(channelId, allowFromCache)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string, bool) store.StoreChannel); ok {
|
|
r0 = rf(channelId, allowFromCache)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetFlaggedPosts provides a mock function with given fields: userId, offset, limit
|
|
func (_m *PostStore) GetFlaggedPosts(userId string, offset int, limit int) store.StoreChannel {
|
|
ret := _m.Called(userId, offset, limit)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string, int, int) store.StoreChannel); ok {
|
|
r0 = rf(userId, offset, limit)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetFlaggedPostsForChannel provides a mock function with given fields: userId, channelId, offset, limit
|
|
func (_m *PostStore) GetFlaggedPostsForChannel(userId string, channelId string, offset int, limit int) store.StoreChannel {
|
|
ret := _m.Called(userId, channelId, offset, limit)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string, string, int, int) store.StoreChannel); ok {
|
|
r0 = rf(userId, channelId, offset, limit)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetFlaggedPostsForTeam provides a mock function with given fields: userId, teamId, offset, limit
|
|
func (_m *PostStore) GetFlaggedPostsForTeam(userId string, teamId string, offset int, limit int) store.StoreChannel {
|
|
ret := _m.Called(userId, teamId, offset, limit)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string, string, int, int) store.StoreChannel); ok {
|
|
r0 = rf(userId, teamId, offset, limit)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetOldest provides a mock function with given fields:
|
|
func (_m *PostStore) GetOldest() store.StoreChannel {
|
|
ret := _m.Called()
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func() store.StoreChannel); ok {
|
|
r0 = rf()
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetPosts provides a mock function with given fields: channelId, offset, limit, allowFromCache
|
|
func (_m *PostStore) GetPosts(channelId string, offset int, limit int, allowFromCache bool) store.StoreChannel {
|
|
ret := _m.Called(channelId, offset, limit, allowFromCache)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string, int, int, bool) store.StoreChannel); ok {
|
|
r0 = rf(channelId, offset, limit, allowFromCache)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetPostsAfter provides a mock function with given fields: channelId, postId, numPosts, offset
|
|
func (_m *PostStore) GetPostsAfter(channelId string, postId string, numPosts int, offset int) store.StoreChannel {
|
|
ret := _m.Called(channelId, postId, numPosts, offset)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string, string, int, int) store.StoreChannel); ok {
|
|
r0 = rf(channelId, postId, numPosts, offset)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetPostsBatchForIndexing provides a mock function with given fields: startTime, endTime, limit
|
|
func (_m *PostStore) GetPostsBatchForIndexing(startTime int64, endTime int64, limit int) store.StoreChannel {
|
|
ret := _m.Called(startTime, endTime, limit)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(int64, int64, int) store.StoreChannel); ok {
|
|
r0 = rf(startTime, endTime, limit)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetPostsBefore provides a mock function with given fields: channelId, postId, numPosts, offset
|
|
func (_m *PostStore) GetPostsBefore(channelId string, postId string, numPosts int, offset int) store.StoreChannel {
|
|
ret := _m.Called(channelId, postId, numPosts, offset)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string, string, int, int) store.StoreChannel); ok {
|
|
r0 = rf(channelId, postId, numPosts, offset)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetPostsByIds provides a mock function with given fields: postIds
|
|
func (_m *PostStore) GetPostsByIds(postIds []string) store.StoreChannel {
|
|
ret := _m.Called(postIds)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func([]string) store.StoreChannel); ok {
|
|
r0 = rf(postIds)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetPostsCreatedAt provides a mock function with given fields: channelId, time
|
|
func (_m *PostStore) GetPostsCreatedAt(channelId string, time int64) store.StoreChannel {
|
|
ret := _m.Called(channelId, time)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok {
|
|
r0 = rf(channelId, time)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetPostsSince provides a mock function with given fields: channelId, time, allowFromCache
|
|
func (_m *PostStore) GetPostsSince(channelId string, time int64, allowFromCache bool) store.StoreChannel {
|
|
ret := _m.Called(channelId, time, allowFromCache)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string, int64, bool) store.StoreChannel); ok {
|
|
r0 = rf(channelId, time, allowFromCache)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetSingle provides a mock function with given fields: id
|
|
func (_m *PostStore) GetSingle(id string) store.StoreChannel {
|
|
ret := _m.Called(id)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
|
r0 = rf(id)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// InvalidateLastPostTimeCache provides a mock function with given fields: channelId
|
|
func (_m *PostStore) InvalidateLastPostTimeCache(channelId string) {
|
|
_m.Called(channelId)
|
|
}
|
|
|
|
// Overwrite provides a mock function with given fields: post
|
|
func (_m *PostStore) Overwrite(post *model.Post) store.StoreChannel {
|
|
ret := _m.Called(post)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(*model.Post) store.StoreChannel); ok {
|
|
r0 = rf(post)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// PermanentDeleteBatch provides a mock function with given fields: endTime, limit
|
|
func (_m *PostStore) PermanentDeleteBatch(endTime int64, limit int64) store.StoreChannel {
|
|
ret := _m.Called(endTime, limit)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(int64, int64) store.StoreChannel); ok {
|
|
r0 = rf(endTime, limit)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// PermanentDeleteByChannel provides a mock function with given fields: channelId
|
|
func (_m *PostStore) PermanentDeleteByChannel(channelId string) store.StoreChannel {
|
|
ret := _m.Called(channelId)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
|
r0 = rf(channelId)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// PermanentDeleteByUser provides a mock function with given fields: userId
|
|
func (_m *PostStore) PermanentDeleteByUser(userId string) store.StoreChannel {
|
|
ret := _m.Called(userId)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
|
r0 = rf(userId)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// Save provides a mock function with given fields: post
|
|
func (_m *PostStore) Save(post *model.Post) store.StoreChannel {
|
|
ret := _m.Called(post)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(*model.Post) store.StoreChannel); ok {
|
|
r0 = rf(post)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// Search provides a mock function with given fields: teamId, userId, params
|
|
func (_m *PostStore) Search(teamId string, userId string, params *model.SearchParams) store.StoreChannel {
|
|
ret := _m.Called(teamId, userId, params)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(string, string, *model.SearchParams) store.StoreChannel); ok {
|
|
r0 = rf(teamId, userId, params)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// Update provides a mock function with given fields: newPost, oldPost
|
|
func (_m *PostStore) Update(newPost *model.Post, oldPost *model.Post) store.StoreChannel {
|
|
ret := _m.Called(newPost, oldPost)
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func(*model.Post, *model.Post) store.StoreChannel); ok {
|
|
r0 = rf(newPost, oldPost)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
func (_m *PostStore) GetMaxPostSize() store.StoreChannel {
|
|
ret := _m.Called()
|
|
|
|
var r0 store.StoreChannel
|
|
if rf, ok := ret.Get(0).(func() store.StoreChannel); ok {
|
|
r0 = rf()
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(store.StoreChannel)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|