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 {
|
for channelKey, setting := range b.Settings {
|
||||||
if setting.IncludeRegex != "" {
|
if setting.IncludeRegex != "" {
|
||||||
included := false
|
included := false
|
||||||
|
|
||||||
includeRegex, err := regexp.Compile(setting.IncludeRegex)
|
includeRegex, err := regexp.Compile(setting.IncludeRegex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error in regexp: %q\n", includeRegex)
|
log.Printf("error in regexp: %q\n", includeRegex)
|
||||||
} else {
|
} else {
|
||||||
if item.Content != nil {
|
included = matchItemText(item, includeRegex)
|
||||||
included = includeRegex.MatchString(item.Content.Text) || includeRegex.MatchString(item.Content.HTML)
|
|
||||||
|
for _, v := range item.Refs {
|
||||||
|
included = included || matchItemText(v, includeRegex)
|
||||||
}
|
}
|
||||||
included = included || includeRegex.MatchString(item.Name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if included {
|
if included {
|
||||||
|
|
@ -705,6 +707,14 @@ func (b *memoryBackend) channelAddItemWithMatcher(conn redis.Conn, channel strin
|
||||||
return b.channelAddItem(conn, channel, item)
|
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 {
|
func (b *memoryBackend) channelAddItem(conn redis.Conn, channel string, item microsub.Item) error {
|
||||||
zchannelKey := fmt.Sprintf("zchannel:%s:posts", channel)
|
zchannelKey := fmt.Sprintf("zchannel:%s:posts", channel)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user