[MM-55595] Use annotated logger in search layer (#25468)

Этот коммит содержится в:
Ben Schumacher
2023-12-04 18:34:57 +01:00
коммит произвёл GitHub
родитель 5a4dba8809
Коммит b2ec1ff8ae
130 изменённых файлов: 2107 добавлений и 1930 удалений

Просмотреть файл

@@ -19,6 +19,7 @@ import (
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/mlog"
"github.com/mattermost/mattermost/server/public/shared/request"
)
const (
@@ -231,7 +232,7 @@ func (b *BleveEngine) IsIndexingSync() bool {
return b.indexSync
}
func (b *BleveEngine) RefreshIndexes() *model.AppError {
func (b *BleveEngine) RefreshIndexes(_ request.CTX) *model.AppError {
return nil
}
@@ -251,7 +252,7 @@ func (b *BleveEngine) GetName() string {
return EngineName
}
func (b *BleveEngine) TestConfig(cfg *model.Config) *model.AppError {
func (b *BleveEngine) TestConfig(rctx request.CTX, cfg *model.Config) *model.AppError {
return nil
}
@@ -271,7 +272,7 @@ func (b *BleveEngine) deleteIndexes() *model.AppError {
return nil
}
func (b *BleveEngine) PurgeIndexes() *model.AppError {
func (b *BleveEngine) PurgeIndexes(rctx request.CTX) *model.AppError {
if *b.cfg.BleveSettings.IndexDir == "" {
return nil
}
@@ -279,7 +280,7 @@ func (b *BleveEngine) PurgeIndexes() *model.AppError {
b.Mutex.Lock()
defer b.Mutex.Unlock()
mlog.Info("PurgeIndexes Bleve")
rctx.Logger().Info("PurgeIndexes Bleve")
if err := b.closeIndexes(); err != nil {
return err
}
@@ -291,7 +292,7 @@ func (b *BleveEngine) PurgeIndexes() *model.AppError {
return b.openIndexes()
}
func (b *BleveEngine) DataRetentionDeleteIndexes(cutoff time.Time) *model.AppError {
func (b *BleveEngine) DataRetentionDeleteIndexes(rctx request.CTX, cutoff time.Time) *model.AppError {
return nil
}

Просмотреть файл

@@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/suite"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/request"
"github.com/mattermost/mattermost/server/v8/channels/store/searchlayer"
"github.com/mattermost/mattermost/server/v8/channels/store/searchtest"
"github.com/mattermost/mattermost/server/v8/channels/store/sqlstore"
@@ -29,10 +30,13 @@ type BleveEngineTestSuite struct {
Store *searchlayer.SearchStore
BleveEngine *BleveEngine
IndexDir string
Context request.CTX
}
func TestBleveEngineTestSuite(t *testing.T) {
suite.Run(t, new(BleveEngineTestSuite))
suite.Run(t, &BleveEngineTestSuite{
Context: request.TestContext(t),
})
}
func (s *BleveEngineTestSuite) setupIndexes() {
@@ -51,7 +55,7 @@ func (s *BleveEngineTestSuite) setupStore() {
s.SQLSettings = storetest.MakeSqlSettings(driverName, false)
var err error
s.SQLStore, err = sqlstore.New(*s.SQLSettings, nil)
s.SQLStore, err = sqlstore.New(*s.SQLSettings, s.Context.Logger(), nil)
if err != nil {
s.Require().FailNow("Cannot initialize store: %s", err.Error())
}
@@ -110,7 +114,7 @@ func (s *BleveEngineTestSuite) TestBleveSearchStoreTests() {
func (s *BleveEngineTestSuite) TestDeleteChannelPosts() {
s.Run("Should remove all the posts that belongs to a channel", func() {
s.BleveEngine.PurgeIndexes()
s.BleveEngine.PurgeIndexes(s.Context)
teamID := model.NewId()
userID := model.NewId()
channelID := model.NewId()
@@ -124,7 +128,7 @@ func (s *BleveEngineTestSuite) TestDeleteChannelPosts() {
appErr := s.SearchEngine.BleveEngine.IndexPost(postToAvoid, teamID)
require.Nil(s.T(), appErr)
s.SearchEngine.BleveEngine.DeleteChannelPosts(channelID)
s.SearchEngine.BleveEngine.DeleteChannelPosts(s.Context, channelID)
doc, err := s.BleveEngine.PostIndex.Document(postToAvoid.Id)
require.NoError(s.T(), err)
@@ -135,7 +139,7 @@ func (s *BleveEngineTestSuite) TestDeleteChannelPosts() {
})
s.Run("Shouldn't do anything if there is not posts for the selected channel", func() {
s.BleveEngine.PurgeIndexes()
s.BleveEngine.PurgeIndexes(s.Context)
teamID := model.NewId()
userID := model.NewId()
channelID := model.NewId()
@@ -144,7 +148,7 @@ func (s *BleveEngineTestSuite) TestDeleteChannelPosts() {
appErr := s.SearchEngine.BleveEngine.IndexPost(post, teamID)
require.Nil(s.T(), appErr)
s.SearchEngine.BleveEngine.DeleteChannelPosts(channelToDeleteID)
s.SearchEngine.BleveEngine.DeleteChannelPosts(s.Context, channelToDeleteID)
_, err := s.BleveEngine.PostIndex.Document(post.Id)
require.NoError(s.T(), err)
@@ -156,7 +160,7 @@ func (s *BleveEngineTestSuite) TestDeleteChannelPosts() {
func (s *BleveEngineTestSuite) TestDeleteUserPosts() {
s.Run("Should remove all the posts that belongs to a user", func() {
s.BleveEngine.PurgeIndexes()
s.BleveEngine.PurgeIndexes(s.Context)
teamID := model.NewId()
userID := model.NewId()
userToAvoidID := model.NewId()
@@ -170,7 +174,7 @@ func (s *BleveEngineTestSuite) TestDeleteUserPosts() {
appErr := s.SearchEngine.BleveEngine.IndexPost(postToAvoid, teamID)
require.Nil(s.T(), appErr)
s.SearchEngine.BleveEngine.DeleteUserPosts(userID)
s.SearchEngine.BleveEngine.DeleteUserPosts(s.Context, userID)
doc, err := s.BleveEngine.PostIndex.Document(postToAvoid.Id)
require.NoError(s.T(), err)
@@ -181,7 +185,7 @@ func (s *BleveEngineTestSuite) TestDeleteUserPosts() {
})
s.Run("Shouldn't do anything if there is not posts for the selected user", func() {
s.BleveEngine.PurgeIndexes()
s.BleveEngine.PurgeIndexes(s.Context)
teamID := model.NewId()
userID := model.NewId()
userToDeleteID := model.NewId()
@@ -190,7 +194,7 @@ func (s *BleveEngineTestSuite) TestDeleteUserPosts() {
appErr := s.SearchEngine.BleveEngine.IndexPost(post, teamID)
require.Nil(s.T(), appErr)
s.SearchEngine.BleveEngine.DeleteUserPosts(userToDeleteID)
s.SearchEngine.BleveEngine.DeleteUserPosts(s.Context, userToDeleteID)
_, err := s.BleveEngine.PostIndex.Document(post.Id)
require.NoError(s.T(), err)
@@ -201,7 +205,7 @@ func (s *BleveEngineTestSuite) TestDeleteUserPosts() {
}
func (s *BleveEngineTestSuite) TestDeletePosts() {
s.BleveEngine.PurgeIndexes()
s.BleveEngine.PurgeIndexes(s.Context)
teamID := model.NewId()
userID := model.NewId()
userToAvoidID := model.NewId()

Просмотреть файл

@@ -12,6 +12,7 @@ import (
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/mlog"
"github.com/mattermost/mattermost/server/public/shared/request"
)
const DeletePostsBatchSize = 500
@@ -255,7 +256,7 @@ func (b *BleveEngine) deletePosts(searchRequest *bleve.SearchRequest, batchSize
return resultsCount, nil
}
func (b *BleveEngine) DeleteChannelPosts(channelID string) *model.AppError {
func (b *BleveEngine) DeleteChannelPosts(rctx request.CTX, channelID string) *model.AppError {
b.Mutex.RLock()
defer b.Mutex.RUnlock()
@@ -269,12 +270,12 @@ func (b *BleveEngine) DeleteChannelPosts(channelID string) *model.AppError {
err.Error(), http.StatusInternalServerError)
}
mlog.Info("Posts for channel deleted", mlog.String("channel_id", channelID), mlog.Int("deleted", deleted))
rctx.Logger().Info("Posts for channel deleted", mlog.String("channel_id", channelID), mlog.Int("deleted", deleted))
return nil
}
func (b *BleveEngine) DeleteUserPosts(userID string) *model.AppError {
func (b *BleveEngine) DeleteUserPosts(rctx request.CTX, userID string) *model.AppError {
b.Mutex.RLock()
defer b.Mutex.RUnlock()
@@ -288,7 +289,7 @@ func (b *BleveEngine) DeleteUserPosts(userID string) *model.AppError {
err.Error(), http.StatusInternalServerError)
}
mlog.Info("Posts for user deleted", mlog.String("user_id", userID), mlog.Int("deleted", deleted))
rctx.Logger().Info("Posts for user deleted", mlog.String("user_id", userID), mlog.Int("deleted", deleted))
return nil
}
@@ -303,7 +304,7 @@ func (b *BleveEngine) DeletePost(post *model.Post) *model.AppError {
return nil
}
func (b *BleveEngine) IndexChannel(channel *model.Channel, userIDs, teamMemberIDs []string) *model.AppError {
func (b *BleveEngine) IndexChannel(_ request.CTX, channel *model.Channel, userIDs, teamMemberIDs []string) *model.AppError {
b.Mutex.RLock()
defer b.Mutex.RUnlock()
@@ -402,7 +403,7 @@ func (b *BleveEngine) DeleteChannel(channel *model.Channel) *model.AppError {
return nil
}
func (b *BleveEngine) IndexUser(user *model.User, teamsIds, channelsIds []string) *model.AppError {
func (b *BleveEngine) IndexUser(_ request.CTX, user *model.User, teamsIds, channelsIds []string) *model.AppError {
b.Mutex.RLock()
defer b.Mutex.RUnlock()
@@ -818,7 +819,7 @@ func (b *BleveEngine) deleteFiles(searchRequest *bleve.SearchRequest, batchSize
return resultsCount, nil
}
func (b *BleveEngine) DeleteUserFiles(userID string) *model.AppError {
func (b *BleveEngine) DeleteUserFiles(rctx request.CTX, userID string) *model.AppError {
b.Mutex.RLock()
defer b.Mutex.RUnlock()
@@ -832,12 +833,12 @@ func (b *BleveEngine) DeleteUserFiles(userID string) *model.AppError {
err.Error(), http.StatusInternalServerError)
}
mlog.Info("Files for user deleted", mlog.String("user_id", userID), mlog.Int("deleted", deleted))
rctx.Logger().Info("Files for user deleted", mlog.String("user_id", userID), mlog.Int("deleted", deleted))
return nil
}
func (b *BleveEngine) DeletePostFiles(postID string) *model.AppError {
func (b *BleveEngine) DeletePostFiles(rctx request.CTX, postID string) *model.AppError {
b.Mutex.RLock()
defer b.Mutex.RUnlock()
@@ -851,12 +852,12 @@ func (b *BleveEngine) DeletePostFiles(postID string) *model.AppError {
err.Error(), http.StatusInternalServerError)
}
mlog.Info("Files for post deleted", mlog.String("post_id", postID), mlog.Int("deleted", deleted))
rctx.Logger().Info("Files for post deleted", mlog.String("post_id", postID), mlog.Int("deleted", deleted))
return nil
}
func (b *BleveEngine) DeleteFilesBatch(endTime, limit int64) *model.AppError {
func (b *BleveEngine) DeleteFilesBatch(rctx request.CTX, endTime, limit int64) *model.AppError {
b.Mutex.RLock()
defer b.Mutex.RUnlock()
@@ -873,7 +874,7 @@ func (b *BleveEngine) DeleteFilesBatch(endTime, limit int64) *model.AppError {
err.Error(), http.StatusInternalServerError)
}
mlog.Info("Files in batch deleted", mlog.Int("endTime", endTime), mlog.Int("limit", limit), mlog.Int("deleted", deleted))
rctx.Logger().Info("Files in batch deleted", mlog.Int("endTime", endTime), mlog.Int("limit", limit), mlog.Int("deleted", deleted))
return nil
}

Просмотреть файл

@@ -7,6 +7,7 @@ import (
"time"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/request"
)
type SearchEngineInterface interface {
@@ -27,25 +28,25 @@ type SearchEngineInterface interface {
IndexPost(post *model.Post, teamId string) *model.AppError
SearchPosts(channels model.ChannelList, searchParams []*model.SearchParams, page, perPage int) ([]string, model.PostSearchMatches, *model.AppError)
DeletePost(post *model.Post) *model.AppError
DeleteChannelPosts(channelID string) *model.AppError
DeleteUserPosts(userID string) *model.AppError
DeleteChannelPosts(rctx request.CTX, channelID string) *model.AppError
DeleteUserPosts(rctx request.CTX, userID string) *model.AppError
// IndexChannel indexes a given channel. The userIDs are only populated
// for private channels.
IndexChannel(channel *model.Channel, userIDs, teamMemberIDs []string) *model.AppError
IndexChannel(rctx request.CTX, channel *model.Channel, userIDs, teamMemberIDs []string) *model.AppError
SearchChannels(teamId, userID, term string, isGuest bool) ([]string, *model.AppError)
DeleteChannel(channel *model.Channel) *model.AppError
IndexUser(user *model.User, teamsIds, channelsIds []string) *model.AppError
IndexUser(rctx request.CTX, user *model.User, teamsIds, channelsIds []string) *model.AppError
SearchUsersInChannel(teamId, channelId string, restrictedToChannels []string, term string, options *model.UserSearchOptions) ([]string, []string, *model.AppError)
SearchUsersInTeam(teamId string, restrictedToChannels []string, term string, options *model.UserSearchOptions) ([]string, *model.AppError)
DeleteUser(user *model.User) *model.AppError
IndexFile(file *model.FileInfo, channelId string) *model.AppError
SearchFiles(channels model.ChannelList, searchParams []*model.SearchParams, page, perPage int) ([]string, *model.AppError)
DeleteFile(fileID string) *model.AppError
DeletePostFiles(postID string) *model.AppError
DeleteUserFiles(userID string) *model.AppError
DeleteFilesBatch(endTime, limit int64) *model.AppError
TestConfig(cfg *model.Config) *model.AppError
PurgeIndexes() *model.AppError
RefreshIndexes() *model.AppError
DataRetentionDeleteIndexes(cutoff time.Time) *model.AppError
DeletePostFiles(rctx request.CTX, postID string) *model.AppError
DeleteUserFiles(rctx request.CTX, userID string) *model.AppError
DeleteFilesBatch(rctx request.CTX, endTime, limit int64) *model.AppError
TestConfig(rctx request.CTX, cfg *model.Config) *model.AppError
PurgeIndexes(rctx request.CTX) *model.AppError
RefreshIndexes(rctx request.CTX) *model.AppError
DataRetentionDeleteIndexes(rctx request.CTX, cutoff time.Time) *model.AppError
}

Просмотреть файл

@@ -6,6 +6,7 @@ package mocks
import (
model "github.com/mattermost/mattermost/server/public/model"
request "github.com/mattermost/mattermost/server/public/shared/request"
mock "github.com/stretchr/testify/mock"
time "time"
@@ -16,13 +17,13 @@ type SearchEngineInterface struct {
mock.Mock
}
// DataRetentionDeleteIndexes provides a mock function with given fields: cutoff
func (_m *SearchEngineInterface) DataRetentionDeleteIndexes(cutoff time.Time) *model.AppError {
ret := _m.Called(cutoff)
// DataRetentionDeleteIndexes provides a mock function with given fields: rctx, cutoff
func (_m *SearchEngineInterface) DataRetentionDeleteIndexes(rctx request.CTX, cutoff time.Time) *model.AppError {
ret := _m.Called(rctx, cutoff)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(time.Time) *model.AppError); ok {
r0 = rf(cutoff)
if rf, ok := ret.Get(0).(func(request.CTX, time.Time) *model.AppError); ok {
r0 = rf(rctx, cutoff)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
@@ -48,13 +49,13 @@ func (_m *SearchEngineInterface) DeleteChannel(channel *model.Channel) *model.Ap
return r0
}
// DeleteChannelPosts provides a mock function with given fields: channelID
func (_m *SearchEngineInterface) DeleteChannelPosts(channelID string) *model.AppError {
ret := _m.Called(channelID)
// DeleteChannelPosts provides a mock function with given fields: rctx, channelID
func (_m *SearchEngineInterface) DeleteChannelPosts(rctx request.CTX, channelID string) *model.AppError {
ret := _m.Called(rctx, channelID)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
r0 = rf(channelID)
if rf, ok := ret.Get(0).(func(request.CTX, string) *model.AppError); ok {
r0 = rf(rctx, channelID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
@@ -80,13 +81,13 @@ func (_m *SearchEngineInterface) DeleteFile(fileID string) *model.AppError {
return r0
}
// DeleteFilesBatch provides a mock function with given fields: endTime, limit
func (_m *SearchEngineInterface) DeleteFilesBatch(endTime int64, limit int64) *model.AppError {
ret := _m.Called(endTime, limit)
// DeleteFilesBatch provides a mock function with given fields: rctx, endTime, limit
func (_m *SearchEngineInterface) DeleteFilesBatch(rctx request.CTX, endTime int64, limit int64) *model.AppError {
ret := _m.Called(rctx, endTime, limit)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(int64, int64) *model.AppError); ok {
r0 = rf(endTime, limit)
if rf, ok := ret.Get(0).(func(request.CTX, int64, int64) *model.AppError); ok {
r0 = rf(rctx, endTime, limit)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
@@ -112,13 +113,13 @@ func (_m *SearchEngineInterface) DeletePost(post *model.Post) *model.AppError {
return r0
}
// DeletePostFiles provides a mock function with given fields: postID
func (_m *SearchEngineInterface) DeletePostFiles(postID string) *model.AppError {
ret := _m.Called(postID)
// DeletePostFiles provides a mock function with given fields: rctx, postID
func (_m *SearchEngineInterface) DeletePostFiles(rctx request.CTX, postID string) *model.AppError {
ret := _m.Called(rctx, postID)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
r0 = rf(postID)
if rf, ok := ret.Get(0).(func(request.CTX, string) *model.AppError); ok {
r0 = rf(rctx, postID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
@@ -144,13 +145,13 @@ func (_m *SearchEngineInterface) DeleteUser(user *model.User) *model.AppError {
return r0
}
// DeleteUserFiles provides a mock function with given fields: userID
func (_m *SearchEngineInterface) DeleteUserFiles(userID string) *model.AppError {
ret := _m.Called(userID)
// DeleteUserFiles provides a mock function with given fields: rctx, userID
func (_m *SearchEngineInterface) DeleteUserFiles(rctx request.CTX, userID string) *model.AppError {
ret := _m.Called(rctx, userID)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
r0 = rf(userID)
if rf, ok := ret.Get(0).(func(request.CTX, string) *model.AppError); ok {
r0 = rf(rctx, userID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
@@ -160,13 +161,13 @@ func (_m *SearchEngineInterface) DeleteUserFiles(userID string) *model.AppError
return r0
}
// DeleteUserPosts provides a mock function with given fields: userID
func (_m *SearchEngineInterface) DeleteUserPosts(userID string) *model.AppError {
ret := _m.Called(userID)
// DeleteUserPosts provides a mock function with given fields: rctx, userID
func (_m *SearchEngineInterface) DeleteUserPosts(rctx request.CTX, userID string) *model.AppError {
ret := _m.Called(rctx, userID)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
r0 = rf(userID)
if rf, ok := ret.Get(0).(func(request.CTX, string) *model.AppError); ok {
r0 = rf(rctx, userID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
@@ -234,13 +235,13 @@ func (_m *SearchEngineInterface) GetVersion() int {
return r0
}
// IndexChannel provides a mock function with given fields: channel, userIDs, teamMemberIDs
func (_m *SearchEngineInterface) IndexChannel(channel *model.Channel, userIDs []string, teamMemberIDs []string) *model.AppError {
ret := _m.Called(channel, userIDs, teamMemberIDs)
// IndexChannel provides a mock function with given fields: rctx, channel, userIDs, teamMemberIDs
func (_m *SearchEngineInterface) IndexChannel(rctx request.CTX, channel *model.Channel, userIDs []string, teamMemberIDs []string) *model.AppError {
ret := _m.Called(rctx, channel, userIDs, teamMemberIDs)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(*model.Channel, []string, []string) *model.AppError); ok {
r0 = rf(channel, userIDs, teamMemberIDs)
if rf, ok := ret.Get(0).(func(request.CTX, *model.Channel, []string, []string) *model.AppError); ok {
r0 = rf(rctx, channel, userIDs, teamMemberIDs)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
@@ -282,13 +283,13 @@ func (_m *SearchEngineInterface) IndexPost(post *model.Post, teamId string) *mod
return r0
}
// IndexUser provides a mock function with given fields: user, teamsIds, channelsIds
func (_m *SearchEngineInterface) IndexUser(user *model.User, teamsIds []string, channelsIds []string) *model.AppError {
ret := _m.Called(user, teamsIds, channelsIds)
// IndexUser provides a mock function with given fields: rctx, user, teamsIds, channelsIds
func (_m *SearchEngineInterface) IndexUser(rctx request.CTX, user *model.User, teamsIds []string, channelsIds []string) *model.AppError {
ret := _m.Called(rctx, user, teamsIds, channelsIds)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(*model.User, []string, []string) *model.AppError); ok {
r0 = rf(user, teamsIds, channelsIds)
if rf, ok := ret.Get(0).(func(request.CTX, *model.User, []string, []string) *model.AppError); ok {
r0 = rf(rctx, user, teamsIds, channelsIds)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
@@ -382,13 +383,13 @@ func (_m *SearchEngineInterface) IsSearchEnabled() bool {
return r0
}
// PurgeIndexes provides a mock function with given fields:
func (_m *SearchEngineInterface) PurgeIndexes() *model.AppError {
ret := _m.Called()
// PurgeIndexes provides a mock function with given fields: rctx
func (_m *SearchEngineInterface) PurgeIndexes(rctx request.CTX) *model.AppError {
ret := _m.Called(rctx)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func() *model.AppError); ok {
r0 = rf()
if rf, ok := ret.Get(0).(func(request.CTX) *model.AppError); ok {
r0 = rf(rctx)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
@@ -398,13 +399,13 @@ func (_m *SearchEngineInterface) PurgeIndexes() *model.AppError {
return r0
}
// RefreshIndexes provides a mock function with given fields:
func (_m *SearchEngineInterface) RefreshIndexes() *model.AppError {
ret := _m.Called()
// RefreshIndexes provides a mock function with given fields: rctx
func (_m *SearchEngineInterface) RefreshIndexes(rctx request.CTX) *model.AppError {
ret := _m.Called(rctx)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func() *model.AppError); ok {
r0 = rf()
if rf, ok := ret.Get(0).(func(request.CTX) *model.AppError); ok {
r0 = rf(rctx)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
@@ -604,13 +605,13 @@ func (_m *SearchEngineInterface) Stop() *model.AppError {
return r0
}
// TestConfig provides a mock function with given fields: cfg
func (_m *SearchEngineInterface) TestConfig(cfg *model.Config) *model.AppError {
ret := _m.Called(cfg)
// TestConfig provides a mock function with given fields: rctx, cfg
func (_m *SearchEngineInterface) TestConfig(rctx request.CTX, cfg *model.Config) *model.AppError {
ret := _m.Called(rctx, cfg)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(*model.Config) *model.AppError); ok {
r0 = rf(cfg)
if rf, ok := ret.Get(0).(func(request.CTX, *model.Config) *model.AppError); ok {
r0 = rf(rctx, cfg)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)

Просмотреть файл

@@ -197,7 +197,7 @@ func (scs *Service) upsertSyncUser(c request.CTX, user *model.User, channel *mod
Timezone: user.Timezone,
RemoteId: user.RemoteId,
}
if userSaved, err = scs.updateSyncUser(patch, euser, channel, rc); err != nil {
if userSaved, err = scs.updateSyncUser(c, patch, euser, channel, rc); err != nil {
return nil, err
}
}
@@ -270,7 +270,7 @@ func (scs *Service) insertSyncUser(user *model.User, channel *model.Channel, rc
return nil, fmt.Errorf("error inserting sync user %s: %w", user.Id, err)
}
func (scs *Service) updateSyncUser(patch *model.UserPatch, user *model.User, channel *model.Channel, rc *model.RemoteCluster) (*model.User, error) {
func (scs *Service) updateSyncUser(rctx request.CTX, patch *model.UserPatch, user *model.User, channel *model.Channel, rc *model.RemoteCluster) (*model.User, error) {
var err error
var update *model.UserUpdate
var suffix string
@@ -301,7 +301,7 @@ func (scs *Service) updateSyncUser(patch *model.UserPatch, user *model.User, cha
user.Username = mungUsername(user.Username, rc.Name, suffix, model.UserNameMaxLength)
user.Email = mungEmail(rc.Name, model.UserEmailMaxLength)
if update, err = scs.server.GetStore().User().Update(user, false); err != nil {
if update, err = scs.server.GetStore().User().Update(rctx, user, false); err != nil {
field, ok := isConflictError(err)
if !ok {
break

Просмотреть файл

@@ -680,7 +680,7 @@ func (si *SlackImporter) oldImportPost(rctx request.CTX, post *model.Post) strin
firstPostId = post.Id
}
for _, fileId := range post.FileIds {
if err := si.store.FileInfo().AttachToPost(fileId, post.Id, post.ChannelId, post.UserId); err != nil {
if err := si.store.FileInfo().AttachToPost(rctx, fileId, post.Id, post.ChannelId, post.UserId); err != nil {
rctx.Logger().Error(
"Error attaching files to post.",
mlog.String("post_id", post.Id),