get channel id for bookmark files in ES/OS (#28221)

Co-authored-by: Miguel de la Cruz <mgdelacroix@gmail.com>
Этот коммит содержится в:
Caleb Roseland
2024-09-19 04:57:10 -05:00
коммит произвёл GitHub
родитель 987a25b4d0
Коммит d6c11d1d26
2 изменённых файлов: 15 добавлений и 6 удалений

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

@@ -20,16 +20,25 @@ func (s SearchFileInfoStore) indexFile(rctx request.CTX, file *model.FileInfo) {
for _, engine := range s.rootStore.searchEngine.GetActiveEngines() {
if engine.IsIndexingEnabled() {
runIndexFn(rctx, engine, func(engineCopy searchengine.SearchEngineInterface) {
if file.PostId == "" {
if file.PostId == "" && file.CreatorId != model.BookmarkFileOwner {
return
}
post, postErr := s.rootStore.Post().GetSingle(rctx, file.PostId, false)
if postErr != nil {
rctx.Logger().Error("Couldn't get post for file for SearchEngine indexing.", mlog.String("post_id", file.PostId), mlog.String("search_engine", engineCopy.GetName()), mlog.String("file_info_id", file.Id), mlog.Err(postErr))
channelId := file.ChannelId
if file.PostId != "" {
post, postErr := s.rootStore.Post().GetSingle(rctx, file.PostId, false)
if postErr != nil {
rctx.Logger().Error("Couldn't get post for file for SearchEngine indexing.", mlog.String("post_id", file.PostId), mlog.String("search_engine", engineCopy.GetName()), mlog.String("file_info_id", file.Id), mlog.Err(postErr))
return
}
channelId = post.ChannelId
}
if channelId == "" {
rctx.Logger().Error("Couldn't associate file with a channel for file for SearchEngine indexing.", mlog.String("search_engine", engineCopy.GetName()), mlog.String("file_info_id", file.Id))
return
}
if err := engineCopy.IndexFile(file, post.ChannelId); err != nil {
if err := engineCopy.IndexFile(file, channelId); err != nil {
rctx.Logger().Error("Encountered error indexing file", mlog.String("file_info_id", file.Id), mlog.String("search_engine", engineCopy.GetName()), mlog.Err(err))
return
}

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

@@ -191,7 +191,7 @@ var searchFileInfoStoreTests = []searchTest{
{
Name: "Should search files part of channel bookmarks",
Fn: testFileInfoSearchShowChannelBookmarkFiles,
Tags: []string{EnginePostgres, EngineMySQL},
Tags: []string{EnginePostgres, EngineMySQL, EngineElasticSearch},
},
}