Also look at referenced items for included text
This commit is contained in:
parent
93a91a4966
commit
8360c178c7
|
@ -654,14 +654,16 @@ func (b *memoryBackend) channelAddItemWithMatcher(conn redis.Conn, channel strin
|
|||
for channelKey, setting := range b.Settings {
|
||||
if setting.IncludeRegex != "" {
|
||||
included := false
|
||||
|
||||
includeRegex, err := regexp.Compile(setting.IncludeRegex)
|
||||
if err != nil {
|
||||
log.Printf("error in regexp: %q\n", includeRegex)
|
||||
} else {
|
||||
if item.Content != nil {
|
||||
included = includeRegex.MatchString(item.Content.Text) || includeRegex.MatchString(item.Content.HTML)
|
||||
included = matchItemText(item, includeRegex)
|
||||
|
||||
for _, v := range item.Refs {
|
||||
included = included || matchItemText(v, includeRegex)
|
||||
}
|
||||
included = included || includeRegex.MatchString(item.Name)
|
||||
}
|
||||
|
||||
if included {
|
||||
|
@ -705,6 +707,14 @@ func (b *memoryBackend) channelAddItemWithMatcher(conn redis.Conn, channel strin
|
|||
return b.channelAddItem(conn, channel, item)
|
||||
}
|
||||
|
||||
func matchItemText(item microsub.Item, includeRegex *regexp.Regexp) bool {
|
||||
var included bool
|
||||
if item.Content != nil {
|
||||
included = includeRegex.MatchString(item.Content.Text) || includeRegex.MatchString(item.Content.HTML)
|
||||
}
|
||||
return included || includeRegex.MatchString(item.Name)
|
||||
}
|
||||
|
||||
func (b *memoryBackend) channelAddItem(conn redis.Conn, channel string, item microsub.Item) error {
|
||||
zchannelKey := fmt.Sprintf("zchannel:%s:posts", channel)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user