Fixed bug around channel file sidebar (#27705)

* Fixed the issue for DB layer, ES to go

* Handled channel bookmarks

* Handled Bleve

* Lint fix

* Added channel bookmark test

* Skip bleve test

* Used common function

* SKipping ES as indexing logic in unavailable in test
Этот коммит содержится в:
Harshil Sharma
2024-07-26 11:45:42 +05:30
коммит произвёл GitHub
родитель d8b01bde2e
Коммит eb6336ce7a
4 изменённых файлов: 62 добавлений и 1 удалений

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

@@ -260,6 +260,22 @@ type FileForIndexing struct {
Content string `json:"content"`
}
// ShouldIndex tells if a file should be indexed or not.
// index files which are-
// a. not deleted
// b. have an associated post ID, if no post ID, then,
// b.i. the file should belong to the channel's bookmarks, as indicated by the "CreatorId" field.
//
// Files not passing this criteria will be deleted from ES index.
// We're deleting those files from ES index instead of simply skipping them while fetching a batch of files
// because existing ES indexes might have these files already indexed, so we need to remove them from index.
func (file *FileForIndexing) ShouldIndex() bool {
// NOTE - this function is used in server as well as Enterprise code.
// Make sure to update public package dependency in both server and Enterprise code when
// updating the logic here and to test both places.
return file != nil && file.DeleteAt == 0 && (file.PostId != "" || file.CreatorId == BookmarkFileOwner)
}
// ShallowCopy is an utility function to shallow copy a Post to the given
// destination without touching the internal RWMutex.
func (o *Post) ShallowCopy(dst *Post) error {