eksterd: add channel to search results
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2021-06-01 00:04:39 +02:00
parent cb6bf8fc05
commit b4cc885103
Signed by: peter
GPG Key ID: 374322D56E5209E8
2 changed files with 10 additions and 4 deletions

View File

@ -606,9 +606,9 @@ func (b *memoryBackend) channelAddItemWithMatcher(channel string, item microsub.
// if regex matches item
// - add item to channel
err := addToSearch(item)
err := addToSearch(item, channel)
if err != nil {
return fmt.Errorf("in channelAddItemWithMatcher: %v", err)
return fmt.Errorf("addToSearch in channelAddItemWithMatcher: %v", err)
}
var updatedChannels []string

View File

@ -27,10 +27,16 @@ func initSearch() error {
return nil
}
func addToSearch(item microsub.Item) error {
type indexItem struct {
microsub.Item
Channel string `json:"channel"`
}
func addToSearch(item microsub.Item, channel string) error {
// TODO: add channel when indexing
if index != nil {
err := index.Index(item.ID, item)
indexItem := indexItem{item, channel}
err := index.Index(item.ID, indexItem)
if err != nil {
return fmt.Errorf("while indexing item: %v", err)
}