diff --git a/app/post.go b/app/post.go index 52e3623755..1200fd47cc 100644 --- a/app/post.go +++ b/app/post.go @@ -1079,6 +1079,7 @@ func (a *App) SearchPostsInTeamForUser(terms string, userId string, teamId strin for _, params := range paramsList { params.OrTerms = isOrSearch + params.IncludeDeletedChannels = includeDeleted // Don't allow users to search for "*" if params.Terms != "*" { // Convert channel names to channel IDs @@ -1098,7 +1099,7 @@ func (a *App) SearchPostsInTeamForUser(terms string, userId string, teamId strin return model.MakePostSearchResults(model.NewPostList(), nil), nil } - postSearchResults, err = a.Srv().Store.Post().SearchPostsInTeamForUser(finalParamsList, userId, teamId, isOrSearch, includeDeleted, page, perPage) + postSearchResults, err = a.Srv().Store.Post().SearchPostsInTeamForUser(finalParamsList, userId, teamId, page, perPage) if err != nil { return nil, err } diff --git a/i18n/en.json b/i18n/en.json index 945c60d8d8..3655e3d558 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -6778,6 +6778,10 @@ "id": "model.reaction.is_valid.user_id.app_error", "translation": "Invalid user id." }, + { + "id": "model.search_params_list.is_valid.include_deleted_channels.app_error", + "translation": "All IncludeDeletedChannels params should have the same value." + }, { "id": "model.team.is_valid.characters.app_error", "translation": "Name must be 2 or more lowercase alphanumeric characters." diff --git a/model/search_params.go b/model/search_params.go index e6dce73c32..d34c8865e9 100644 --- a/model/search_params.go +++ b/model/search_params.go @@ -4,6 +4,7 @@ package model import ( + "net/http" "regexp" "strings" "time" @@ -367,3 +368,13 @@ func ParseSearchParams(text string, timeZoneOffset int) []*SearchParams { return paramsList } + +func IsSearchParamsListValid(paramsList []*SearchParams) *AppError { + // All SearchParams should have same IncludeDeletedChannels value. + for _, params := range paramsList { + if params.IncludeDeletedChannels != paramsList[0].IncludeDeletedChannels { + return NewAppError("IsSearchParamsListValid", "model.search_params_list.is_valid.include_deleted_channels.app_error", nil, "", http.StatusInternalServerError) + } + } + return nil +} diff --git a/model/search_params_test.go b/model/search_params_test.go index db162d9556..d8bf5296b4 100644 --- a/model/search_params_test.go +++ b/model/search_params_test.go @@ -1618,3 +1618,19 @@ func TestGetAfterDateMillis(t *testing.T) { }) } } + +func TestIsSearchParamsListValid(t *testing.T) { + var err *AppError + + err = IsSearchParamsListValid([]*SearchParams{{IncludeDeletedChannels: true}, {IncludeDeletedChannels: true}}) + assert.Nil(t, err) + + err = IsSearchParamsListValid([]*SearchParams{{IncludeDeletedChannels: true}, {IncludeDeletedChannels: false}}) + assert.NotNil(t, err) + + err = IsSearchParamsListValid([]*SearchParams{{IncludeDeletedChannels: true}}) + assert.Nil(t, err) + + err = IsSearchParamsListValid([]*SearchParams{}) + assert.Nil(t, err) +} diff --git a/store/opentracinglayer/opentracinglayer.go b/store/opentracinglayer/opentracinglayer.go index 1a3e051711..f9e45fb869 100644 --- a/store/opentracinglayer/opentracinglayer.go +++ b/store/opentracinglayer/opentracinglayer.go @@ -5329,7 +5329,7 @@ func (s *OpenTracingLayerPostStore) Search(teamId string, userId string, params return result, err } -func (s *OpenTracingLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, isOrSearch bool, includeDeletedChannels bool, page int, perPage int) (*model.PostSearchResults, *model.AppError) { +func (s *OpenTracingLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, *model.AppError) { origCtx := s.Root.Store.Context() span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "PostStore.SearchPostsInTeamForUser") s.Root.Store.SetContext(newCtx) @@ -5338,7 +5338,7 @@ func (s *OpenTracingLayerPostStore) SearchPostsInTeamForUser(paramsList []*model }() defer span.Finish() - result, err := s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamId, isOrSearch, includeDeletedChannels, page, perPage) + result, err := s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamId, page, perPage) if err != nil { span.LogFields(spanlog.Error(err)) ext.Error.Set(span, true) diff --git a/store/retrylayer/retrylayer.go b/store/retrylayer/retrylayer.go index 32d24b700b..5dfe0a43a2 100644 --- a/store/retrylayer/retrylayer.go +++ b/store/retrylayer/retrylayer.go @@ -3860,9 +3860,9 @@ func (s *RetryLayerPostStore) Search(teamId string, userId string, params *model } -func (s *RetryLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, isOrSearch bool, includeDeletedChannels bool, page int, perPage int) (*model.PostSearchResults, *model.AppError) { +func (s *RetryLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, *model.AppError) { - return s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamId, isOrSearch, includeDeletedChannels, page, perPage) + return s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamId, page, perPage) } diff --git a/store/searchlayer/post_layer.go b/store/searchlayer/post_layer.go index 577b2d0de7..cf3bd97885 100644 --- a/store/searchlayer/post_layer.go +++ b/store/searchlayer/post_layer.go @@ -131,9 +131,13 @@ func (s SearchPostStore) PermanentDeleteByChannel(channelID string) error { return err } -func (s SearchPostStore) searchPostsInTeamForUserByEngine(engine searchengine.SearchEngineInterface, paramsList []*model.SearchParams, userId, teamId string, isOrSearch, includeDeletedChannels bool, page, perPage int) (*model.PostSearchResults, *model.AppError) { +func (s SearchPostStore) searchPostsInTeamForUserByEngine(engine searchengine.SearchEngineInterface, paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, *model.AppError) { + if err := model.IsSearchParamsListValid(paramsList); err != nil { + return nil, err + } + // We only allow the user to search in channels they are a member of. - userChannels, nErr := s.rootStore.Channel().GetChannels(teamId, userId, includeDeletedChannels, 0) + userChannels, nErr := s.rootStore.Channel().GetChannels(teamId, userId, paramsList[0].IncludeDeletedChannels, 0) if nErr != nil { mlog.Error("error getting channel for user", mlog.Err(nErr)) var nfErr *store.ErrNotFound @@ -169,10 +173,10 @@ func (s SearchPostStore) searchPostsInTeamForUserByEngine(engine searchengine.Se return model.MakePostSearchResults(postList, matches), nil } -func (s SearchPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, isOrSearch, includeDeletedChannels bool, page, perPage int) (*model.PostSearchResults, *model.AppError) { +func (s SearchPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, *model.AppError) { for _, engine := range s.rootStore.searchEngine.GetActiveEngines() { if engine.IsSearchEnabled() { - results, err := s.searchPostsInTeamForUserByEngine(engine, paramsList, userId, teamId, isOrSearch, includeDeletedChannels, page, perPage) + results, err := s.searchPostsInTeamForUserByEngine(engine, paramsList, userId, teamId, page, perPage) if err != nil { mlog.Error("Encountered error on SearchPostsInTeamForUser.", mlog.String("search_engine", engine.GetName()), mlog.Err(err)) continue @@ -188,5 +192,5 @@ func (s SearchPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchPara } mlog.Debug("Using database search because no other search engine is available") - return s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamId, isOrSearch, includeDeletedChannels, page, perPage) + return s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamId, page, perPage) } diff --git a/store/searchtest/post_layer.go b/store/searchtest/post_layer.go index ed70663269..0b336afb9a 100644 --- a/store/searchtest/post_layer.go +++ b/store/searchtest/post_layer.go @@ -96,7 +96,7 @@ var searchPostStoreTests = []searchTest{ { Name: "Should be able to search using boolean operators", Fn: testSearchUsingBooleanOperators, - Tags: []string{ENGINE_ELASTICSEARCH}, + Tags: []string{ENGINE_MYSQL, ENGINE_POSTGRES, ENGINE_ELASTICSEARCH}, }, { Name: "Should be able to search with combined filters", @@ -195,11 +195,9 @@ var searchPostStoreTests = []searchTest{ Tags: []string{ENGINE_ALL}, }, { - Name: "Should be able to search in deleted/archived channels", - Fn: testSearchInDeletedOrArchivedChannels, - Tags: []string{ENGINE_ALL}, - Skip: true, - SkipMessage: "Not working", + Name: "Should be able to search in deleted/archived channels", + Fn: testSearchInDeletedOrArchivedChannels, + Tags: []string{ENGINE_MYSQL, ENGINE_POSTGRES}, }, { Name: "Should be able to search terms with dashes", @@ -211,12 +209,12 @@ var searchPostStoreTests = []searchTest{ { Name: "Should be able to search terms with dots", Fn: testSearchTermsWithDots, - Tags: []string{ENGINE_ELASTICSEARCH}, + Tags: []string{ENGINE_POSTGRES, ENGINE_ELASTICSEARCH}, }, { Name: "Should be able to search terms with underscores", Fn: testSearchTermsWithUnderscores, - Tags: []string{ENGINE_ELASTICSEARCH}, + Tags: []string{ENGINE_MYSQL, ENGINE_ELASTICSEARCH}, }, { Name: "Should be able to search posts made by bot accounts", @@ -290,7 +288,7 @@ func testSearchPostsIncludingDMs(t *testing.T, th *SearchTestHelper) { defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "test"} - results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, err) require.Len(t, results.Posts, 2) @@ -312,13 +310,13 @@ func testSearchPostsWithPagination(t *testing.T, th *SearchTestHelper) { defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "test"} - results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 1) + results, err := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 1) require.Nil(t, err) require.Len(t, results.Posts, 1) th.checkPostInSearchResults(t, p2.Id, results.Posts) - results, err = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 1, 1) + results, err = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 1, 1) require.Nil(t, err) require.Len(t, results.Posts, 1) @@ -333,7 +331,7 @@ func testSearchReturnPinnedAndUnpinned(t *testing.T, th *SearchTestHelper) { defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "test"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -349,7 +347,7 @@ func testSearchExactPhraseInQuotes(t *testing.T, th *SearchTestHelper) { defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "\"channel test 1 2 3\""} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -365,7 +363,7 @@ func testSearchEmailAddresses(t *testing.T, th *SearchTestHelper) { t.Run("Should search email addresses enclosed by quotes", func(t *testing.T) { params := &model.SearchParams{Terms: "\"test@test.com\""} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -374,7 +372,7 @@ func testSearchEmailAddresses(t *testing.T, th *SearchTestHelper) { t.Run("Should search email addresses without quotes", func(t *testing.T) { params := &model.SearchParams{Terms: "test@test.com"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -389,7 +387,7 @@ func testSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) { t.Run("Should search the start inside the markdown underscore", func(t *testing.T) { params := &model.SearchParams{Terms: "start"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -398,7 +396,7 @@ func testSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) { t.Run("Should search a word in the middle of the markdown underscore", func(t *testing.T) { params := &model.SearchParams{Terms: "middle"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -407,7 +405,7 @@ func testSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) { t.Run("Should search in the end of the markdown underscore", func(t *testing.T) { params := &model.SearchParams{Terms: "end"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -416,7 +414,7 @@ func testSearchMarkdownUnderscores(t *testing.T, th *SearchTestHelper) { t.Run("Should search inside markdown underscore", func(t *testing.T) { params := &model.SearchParams{Terms: "another"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -434,7 +432,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) { t.Run("Should search one word", func(t *testing.T) { params := &model.SearchParams{Terms: "你"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -442,7 +440,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) { }) t.Run("Should search two words", func(t *testing.T) { params := &model.SearchParams{Terms: "你好"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -450,7 +448,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) { }) t.Run("Should search with wildcard", func(t *testing.T) { params := &model.SearchParams{Terms: "你*"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -465,7 +463,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) { t.Run("Should search one word", func(t *testing.T) { params := &model.SearchParams{Terms: "слово"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -473,7 +471,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) { }) t.Run("Should search using wildcard", func(t *testing.T) { params := &model.SearchParams{Terms: "слов*"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -490,7 +488,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) { t.Run("Should search one word", func(t *testing.T) { params := &model.SearchParams{Terms: "本"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -499,7 +497,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) { }) t.Run("Should search two words", func(t *testing.T) { params := &model.SearchParams{Terms: "本木"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -507,7 +505,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) { }) t.Run("Should search with wildcard", func(t *testing.T) { params := &model.SearchParams{Terms: "本*"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -525,7 +523,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) { t.Run("Should search one word", func(t *testing.T) { params := &model.SearchParams{Terms: "불"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -533,7 +531,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) { }) t.Run("Should search two words", func(t *testing.T) { params := &model.SearchParams{Terms: "불다"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -541,7 +539,7 @@ func testSearchNonLatinWords(t *testing.T, th *SearchTestHelper) { }) t.Run("Should search with wildcard", func(t *testing.T) { params := &model.SearchParams{Terms: "불*"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -559,7 +557,7 @@ func testSearchAlternativeSpellings(t *testing.T, th *SearchTestHelper) { defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "Straße"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -567,7 +565,7 @@ func testSearchAlternativeSpellings(t *testing.T, th *SearchTestHelper) { th.checkPostInSearchResults(t, p2.Id, results.Posts) params = &model.SearchParams{Terms: "Strasse"} - results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -583,7 +581,7 @@ func testSearchAlternativeSpellingsAccents(t *testing.T, th *SearchTestHelper) { defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "café"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -591,7 +589,7 @@ func testSearchAlternativeSpellingsAccents(t *testing.T, th *SearchTestHelper) { th.checkPostInSearchResults(t, p2.Id, results.Posts) params = &model.SearchParams{Terms: "café"} - results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -599,7 +597,7 @@ func testSearchAlternativeSpellingsAccents(t *testing.T, th *SearchTestHelper) { th.checkPostInSearchResults(t, p2.Id, results.Posts) params = &model.SearchParams{Terms: "cafe"} - results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 0) @@ -617,7 +615,7 @@ func testSearchOrExcludePostsBySpecificUser(t *testing.T, th *SearchTestHelper) Terms: "fromuser", FromUsers: []string{th.User.Id}, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -636,7 +634,7 @@ func testSearchOrExcludePostsInChannel(t *testing.T, th *SearchTestHelper) { Terms: "fromuser", InChannels: []string{th.ChannelBasic.Id}, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -664,7 +662,7 @@ func testSearchOrExcludePostsInDMGM(t *testing.T, th *SearchTestHelper) { Terms: "fromuser", InChannels: []string{direct.Id, group.Id}, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -677,7 +675,7 @@ func testSearchOrExcludePostsInDMGM(t *testing.T, th *SearchTestHelper) { Terms: "fromuser", InChannels: []string{direct.Id}, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -689,7 +687,7 @@ func testSearchOrExcludePostsInDMGM(t *testing.T, th *SearchTestHelper) { Terms: "fromuser", InChannels: []string{group.Id}, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -714,7 +712,7 @@ func testFilterMessagesInSpecificDate(t *testing.T, th *SearchTestHelper) { Terms: "test", OnDate: "2020-03-22", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -725,7 +723,7 @@ func testFilterMessagesInSpecificDate(t *testing.T, th *SearchTestHelper) { Terms: "test", ExcludedDate: "2020-03-22", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -751,7 +749,7 @@ func testFilterMessagesBeforeSpecificDate(t *testing.T, th *SearchTestHelper) { Terms: "test", BeforeDate: "2020-03-23", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -764,7 +762,7 @@ func testFilterMessagesBeforeSpecificDate(t *testing.T, th *SearchTestHelper) { Terms: "test", ExcludedBeforeDate: "2020-03-23", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -789,7 +787,7 @@ func testFilterMessagesAfterSpecificDate(t *testing.T, th *SearchTestHelper) { Terms: "test", AfterDate: "2020-03-23", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -801,7 +799,7 @@ func testFilterMessagesAfterSpecificDate(t *testing.T, th *SearchTestHelper) { Terms: "test", ExcludedAfterDate: "2020-03-23", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -824,7 +822,7 @@ func testFilterMessagesWithATerm(t *testing.T, th *SearchTestHelper) { Terms: "one", ExcludedTerms: "five eight", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -836,7 +834,7 @@ func testFilterMessagesWithATerm(t *testing.T, th *SearchTestHelper) { Terms: "one", ExcludedTerms: "\"eight nine\"", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -859,7 +857,7 @@ func testSearchUsingBooleanOperators(t *testing.T, th *SearchTestHelper) { Terms: "one two", OrTerms: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -872,7 +870,7 @@ func testSearchUsingBooleanOperators(t *testing.T, th *SearchTestHelper) { Terms: "one two", OrTerms: false, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -899,7 +897,7 @@ func testSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper) { FromUsers: []string{th.User2.Id}, InChannels: []string{th.ChannelPrivate.Id}, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -912,7 +910,7 @@ func testSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper) { ExcludedUsers: []string{th.User2.Id}, InChannels: []string{th.ChannelPrivate.Id}, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -926,7 +924,7 @@ func testSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper) { ExcludedAfterDate: "2020-03-11", InChannels: []string{th.ChannelPrivate.Id}, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -938,7 +936,7 @@ func testSearchUsingCombinedFilters(t *testing.T, th *SearchTestHelper) { AfterDate: "2020-03-11", ExcludedChannels: []string{th.ChannelPrivate.Id}, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -961,7 +959,7 @@ func testSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) { params := &model.SearchParams{ Terms: "the search", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -972,7 +970,7 @@ func testSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) { params := &model.SearchParams{ Terms: "a avoid", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -983,7 +981,7 @@ func testSearchIgnoringStopWords(t *testing.T, th *SearchTestHelper) { params := &model.SearchParams{ Terms: "in where you", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1016,7 +1014,7 @@ func testSupportStemming(t *testing.T, th *SearchTestHelper) { params := &model.SearchParams{ Terms: "search", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -1036,7 +1034,7 @@ func testSupportWildcards(t *testing.T, th *SearchTestHelper) { params := &model.SearchParams{ Terms: "search*", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -1056,7 +1054,7 @@ func testNotSupportPrecedingWildcards(t *testing.T, th *SearchTestHelper) { params := &model.SearchParams{ Terms: "*earch", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 0) @@ -1072,7 +1070,7 @@ func testSearchDiscardWildcardAlone(t *testing.T, th *SearchTestHelper) { params := &model.SearchParams{ Terms: "qwerty *", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1090,7 +1088,7 @@ func testSupportTermsWithDash(t *testing.T, th *SearchTestHelper) { params := &model.SearchParams{ Terms: "term-with-dash", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1101,7 +1099,7 @@ func testSupportTermsWithDash(t *testing.T, th *SearchTestHelper) { params := &model.SearchParams{ Terms: "\"term-with-dash\"", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1120,7 +1118,7 @@ func testSupportTermsWithUnderscore(t *testing.T, th *SearchTestHelper) { params := &model.SearchParams{ Terms: "term_with_underscore", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1131,7 +1129,7 @@ func testSupportTermsWithUnderscore(t *testing.T, th *SearchTestHelper) { params := &model.SearchParams{ Terms: "\"term_with_underscore\"", } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1153,7 +1151,7 @@ func testSearchOrExcludePostsWithHashtags(t *testing.T, th *SearchTestHelper) { Terms: "#hashtag", IsHashtag: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -1166,7 +1164,7 @@ func testSearchOrExcludePostsWithHashtags(t *testing.T, th *SearchTestHelper) { Terms: "#hashtag", IsHashtag: false, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -1192,7 +1190,7 @@ func testSearchHashtagWithMarkdown(t *testing.T, th *SearchTestHelper) { Terms: "#hashtag", IsHashtag: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 5) @@ -1215,7 +1213,7 @@ func testSearcWithMultipleHashtags(t *testing.T, th *SearchTestHelper) { Terms: "#hashone #hashtwo", IsHashtag: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1228,7 +1226,7 @@ func testSearcWithMultipleHashtags(t *testing.T, th *SearchTestHelper) { IsHashtag: true, OrTerms: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -1246,7 +1244,7 @@ func testSearchPostsWithDotsInHashtags(t *testing.T, th *SearchTestHelper) { Terms: "#hashtag.dot", IsHashtag: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1267,7 +1265,7 @@ func testSearchHashtagCaseInsensitive(t *testing.T, th *SearchTestHelper) { Terms: "#hashtag", IsHashtag: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 3) @@ -1281,7 +1279,7 @@ func testSearchHashtagCaseInsensitive(t *testing.T, th *SearchTestHelper) { Terms: "#HASHTAG", IsHashtag: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 3) @@ -1295,7 +1293,7 @@ func testSearchHashtagCaseInsensitive(t *testing.T, th *SearchTestHelper) { Terms: "#HaShTaG", IsHashtag: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 3) @@ -1316,7 +1314,7 @@ func testSearchHashtagWithDash(t *testing.T, th *SearchTestHelper) { Terms: "#hashtag-test", IsHashtag: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1334,7 +1332,7 @@ func testSearchHashtagWithNumbers(t *testing.T, th *SearchTestHelper) { Terms: "#h4sht4g", IsHashtag: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1352,7 +1350,7 @@ func testSearchHashtagWithDots(t *testing.T, th *SearchTestHelper) { Terms: "#hashtag.test", IsHashtag: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1370,7 +1368,7 @@ func testSearchHashtagWithUnderscores(t *testing.T, th *SearchTestHelper) { Terms: "#hashtag_test", IsHashtag: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1393,7 +1391,7 @@ func testSearchShouldExcludeSytemMessages(t *testing.T, th *SearchTestHelper) { defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "test system"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 0) @@ -1409,7 +1407,7 @@ func testSearchShouldBeAbleToMatchByMentions(t *testing.T, th *SearchTestHelper) defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "@testuser"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 3) @@ -1429,7 +1427,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) { t.Run("Doesn't include posts in deleted channels", func(t *testing.T) { params := &model.SearchParams{Terms: "message", IncludeDeletedChannels: false} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -1439,7 +1437,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) { t.Run("Include posts in deleted channels", func(t *testing.T) { params := &model.SearchParams{Terms: "message", IncludeDeletedChannels: true} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 3) @@ -1450,7 +1448,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) { t.Run("Include posts in deleted channels using multiple terms", func(t *testing.T) { params := &model.SearchParams{Terms: "message channel", IncludeDeletedChannels: true} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 3) @@ -1465,7 +1463,7 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) { IncludeDeletedChannels: true, OrTerms: true, } - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 3) @@ -1473,6 +1471,20 @@ func testSearchInDeletedOrArchivedChannels(t *testing.T, th *SearchTestHelper) { th.checkPostInSearchResults(t, p2.Id, results.Posts) th.checkPostInSearchResults(t, p3.Id, results.Posts) }) + + t.Run("All IncludeDeletedChannels params should have same value if multiple SearchParams provided", func(t *testing.T) { + params1 := &model.SearchParams{ + Terms: "message channel", + IncludeDeletedChannels: true, + } + params2 := &model.SearchParams{ + Terms: "#hashtag", + IncludeDeletedChannels: false, + } + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params1, params2}, th.User.Id, th.Team.Id, 0, 20) + require.Nil(t, results) + require.NotNil(t, apperr) + }) } func testSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) { @@ -1484,7 +1496,7 @@ func testSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) { t.Run("Search for terms with dash", func(t *testing.T) { params := &model.SearchParams{Terms: "with-dash-term"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1493,7 +1505,7 @@ func testSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) { t.Run("Search for terms with quoted dash", func(t *testing.T) { params := &model.SearchParams{Terms: "\"with-dash-term\""} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1502,7 +1514,7 @@ func testSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) { t.Run("Search for multiple terms with one having dash", func(t *testing.T) { params := &model.SearchParams{Terms: "with-dash-term message"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1511,7 +1523,7 @@ func testSearchTermsWithDashes(t *testing.T, th *SearchTestHelper) { t.Run("Search for multiple OR terms with one having dash", func(t *testing.T) { params := &model.SearchParams{Terms: "with-dash-term message", OrTerms: true} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -1529,7 +1541,7 @@ func testSearchTermsWithDots(t *testing.T, th *SearchTestHelper) { t.Run("Search for terms with dots", func(t *testing.T) { params := &model.SearchParams{Terms: "with.dots.term"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1538,7 +1550,7 @@ func testSearchTermsWithDots(t *testing.T, th *SearchTestHelper) { t.Run("Search for terms with quoted dots", func(t *testing.T) { params := &model.SearchParams{Terms: "\"with.dots.term\""} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1547,7 +1559,7 @@ func testSearchTermsWithDots(t *testing.T, th *SearchTestHelper) { t.Run("Search for multiple terms with one having dots", func(t *testing.T) { params := &model.SearchParams{Terms: "with.dots.term message"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1556,7 +1568,7 @@ func testSearchTermsWithDots(t *testing.T, th *SearchTestHelper) { t.Run("Search for multiple OR terms with one having dots", func(t *testing.T) { params := &model.SearchParams{Terms: "with.dots.term message", OrTerms: true} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -1574,7 +1586,7 @@ func testSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper) { t.Run("Search for terms with underscores", func(t *testing.T) { params := &model.SearchParams{Terms: "with_underscores_term"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1583,7 +1595,7 @@ func testSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper) { t.Run("Search for terms with quoted underscores", func(t *testing.T) { params := &model.SearchParams{Terms: "\"with_underscores_term\""} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1592,7 +1604,7 @@ func testSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper) { t.Run("Search for multiple terms with one having underscores", func(t *testing.T) { params := &model.SearchParams{Terms: "with_underscores_term message"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1601,7 +1613,7 @@ func testSearchTermsWithUnderscores(t *testing.T, th *SearchTestHelper) { t.Run("Search for multiple OR terms with one having underscores", func(t *testing.T) { params := &model.SearchParams{Terms: "with_underscores_term message", OrTerms: true} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -1623,7 +1635,7 @@ func testSearchBotAccountsPosts(t *testing.T, th *SearchTestHelper) { defer th.deleteUserPosts(bot.UserId) params := &model.SearchParams{Terms: "bot"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -1642,7 +1654,7 @@ func testSupportStemmingAndWildcards(t *testing.T, th *SearchTestHelper) { t.Run("Should stem appr", func(t *testing.T) { params := &model.SearchParams{Terms: "appr*"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 3) @@ -1653,7 +1665,7 @@ func testSupportStemmingAndWildcards(t *testing.T, th *SearchTestHelper) { t.Run("Should stem approve", func(t *testing.T) { params := &model.SearchParams{Terms: "approve*"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1670,7 +1682,7 @@ func testSupportWildcardOutsideQuotes(t *testing.T, th *SearchTestHelper) { t.Run("Should return results without quotes", func(t *testing.T) { params := &model.SearchParams{Terms: "hell*"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 2) @@ -1680,7 +1692,7 @@ func testSupportWildcardOutsideQuotes(t *testing.T, th *SearchTestHelper) { t.Run("Should return just one result with quotes", func(t *testing.T) { params := &model.SearchParams{Terms: "\"hell\"*"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1699,7 +1711,7 @@ func testHashtagSearchShouldSupportThreeOrMoreCharacters(t *testing.T, th *Searc defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "#123", IsHashtag: true} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1712,21 +1724,21 @@ func testSlashShouldNotBeCharSeparator(t *testing.T, th *SearchTestHelper) { defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "gamma"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) th.checkPostInSearchResults(t, p1.Id, results.Posts) params = &model.SearchParams{Terms: "beta"} - results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) th.checkPostInSearchResults(t, p1.Id, results.Posts) params = &model.SearchParams{Terms: "alpha"} - results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr = th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1741,7 +1753,7 @@ func testSearchEmailsWithoutQuotes(t *testing.T, th *SearchTestHelper) { defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "test@test.com"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1756,7 +1768,7 @@ func testSupportSearchInComments(t *testing.T, th *SearchTestHelper) { defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "reply"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1769,7 +1781,7 @@ func testSupportSearchTermsWithinLinks(t *testing.T, th *SearchTestHelper) { defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "wikipedia"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 1) @@ -1782,7 +1794,7 @@ func testShouldNotReturnLinksEmbeddedInMarkdown(t *testing.T, th *SearchTestHelp defer th.deleteUserPosts(th.User.Id) params := &model.SearchParams{Terms: "wikipedia"} - results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, false, false, 0, 20) + results, apperr := th.Store.Post().SearchPostsInTeamForUser([]*model.SearchParams{params}, th.User.Id, th.Team.Id, 0, 20) require.Nil(t, apperr) require.Len(t, results.Posts, 0) diff --git a/store/sqlstore/post_store.go b/store/sqlstore/post_store.go index caffeed2b6..82b741b392 100644 --- a/store/sqlstore/post_store.go +++ b/store/sqlstore/post_store.go @@ -1804,12 +1804,16 @@ func (s *SqlPostStore) GetDirectPostParentsForExportAfter(limit int, afterId str return posts, nil } -func (s *SqlPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, isOrSearch, includeDeletedChannels bool, page, perPage int) (*model.PostSearchResults, *model.AppError) { +func (s *SqlPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, *model.AppError) { // Since we don't support paging for DB search, we just return nothing for later pages if page > 0 { return model.MakePostSearchResults(model.NewPostList(), nil), nil } + if err := model.IsSearchParamsListValid(paramsList); err != nil { + return nil, err + } + var wg sync.WaitGroup pchan := make(chan store.StoreResult, len(paramsList)) @@ -1818,8 +1822,6 @@ func (s *SqlPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams // remove any unquoted term that contains only non-alphanumeric chars // ex: abcd "**" && abc >> abcd "**" abc params.Terms = removeNonAlphaNumericUnquotedTerms(params.Terms, " ") - params.IncludeDeletedChannels = includeDeletedChannels - params.OrTerms = isOrSearch wg.Add(1) diff --git a/store/store.go b/store/store.go index b67d59a2cd..af4271489f 100644 --- a/store/store.go +++ b/store/store.go @@ -282,7 +282,7 @@ type PostStore interface { GetParentsForExportAfter(limit int, afterId string) ([]*model.PostForExport, *model.AppError) GetRepliesForExport(parentId string) ([]*model.ReplyForExport, *model.AppError) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, *model.AppError) - SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, isOrSearch, includeDeletedChannels bool, page, perPage int) (*model.PostSearchResults, *model.AppError) + SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId, teamId string, page, perPage int) (*model.PostSearchResults, *model.AppError) GetOldestEntityCreationTime() (int64, *model.AppError) } diff --git a/store/storetest/mocks/PostStore.go b/store/storetest/mocks/PostStore.go index e489a1f04d..f5fb96e50c 100644 --- a/store/storetest/mocks/PostStore.go +++ b/store/storetest/mocks/PostStore.go @@ -815,13 +815,13 @@ func (_m *PostStore) Search(teamId string, userId string, params *model.SearchPa return r0, r1 } -// SearchPostsInTeamForUser provides a mock function with given fields: paramsList, userId, teamId, isOrSearch, includeDeletedChannels, page, perPage -func (_m *PostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, isOrSearch bool, includeDeletedChannels bool, page int, perPage int) (*model.PostSearchResults, *model.AppError) { - ret := _m.Called(paramsList, userId, teamId, isOrSearch, includeDeletedChannels, page, perPage) +// SearchPostsInTeamForUser provides a mock function with given fields: paramsList, userId, teamId, page, perPage +func (_m *PostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, *model.AppError) { + ret := _m.Called(paramsList, userId, teamId, page, perPage) var r0 *model.PostSearchResults - if rf, ok := ret.Get(0).(func([]*model.SearchParams, string, string, bool, bool, int, int) *model.PostSearchResults); ok { - r0 = rf(paramsList, userId, teamId, isOrSearch, includeDeletedChannels, page, perPage) + if rf, ok := ret.Get(0).(func([]*model.SearchParams, string, string, int, int) *model.PostSearchResults); ok { + r0 = rf(paramsList, userId, teamId, page, perPage) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*model.PostSearchResults) @@ -829,8 +829,8 @@ func (_m *PostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, } var r1 *model.AppError - if rf, ok := ret.Get(1).(func([]*model.SearchParams, string, string, bool, bool, int, int) *model.AppError); ok { - r1 = rf(paramsList, userId, teamId, isOrSearch, includeDeletedChannels, page, perPage) + if rf, ok := ret.Get(1).(func([]*model.SearchParams, string, string, int, int) *model.AppError); ok { + r1 = rf(paramsList, userId, teamId, page, perPage) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(*model.AppError) diff --git a/store/timerlayer/timerlayer.go b/store/timerlayer/timerlayer.go index 388c5004ef..b35e34cb4b 100644 --- a/store/timerlayer/timerlayer.go +++ b/store/timerlayer/timerlayer.go @@ -4829,10 +4829,10 @@ func (s *TimerLayerPostStore) Search(teamId string, userId string, params *model return result, err } -func (s *TimerLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, isOrSearch bool, includeDeletedChannels bool, page int, perPage int) (*model.PostSearchResults, *model.AppError) { +func (s *TimerLayerPostStore) SearchPostsInTeamForUser(paramsList []*model.SearchParams, userId string, teamId string, page int, perPage int) (*model.PostSearchResults, *model.AppError) { start := timemodule.Now() - result, err := s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamId, isOrSearch, includeDeletedChannels, page, perPage) + result, err := s.PostStore.SearchPostsInTeamForUser(paramsList, userId, teamId, page, perPage) elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) if s.Root.Metrics != nil {