Fix actual include code
This commit is contained in:
parent
f2d9d450d0
commit
aa22931786
|
@ -373,25 +373,28 @@ func (b *memoryBackend) Fetch3(channel, fetchURL string) (*http.Response, error)
|
||||||
return Fetch2(fetchURL)
|
return Fetch2(fetchURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *memoryBackend) channelAddItem(conn redis.Conn, channel string, item microsub.Item) error {
|
func (b *memoryBackend) channelAddItemWithMatcher(conn redis.Conn, channel string, item microsub.Item) error {
|
||||||
zchannelKey := fmt.Sprintf("zchannel:%s:posts", channel)
|
for channelKey, setting := range b.Settings {
|
||||||
|
|
||||||
for _, setting := range b.Settings {
|
|
||||||
if setting.IncludeRegex != "" {
|
if setting.IncludeRegex != "" {
|
||||||
|
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 && includeRegex.MatchString(item.Content.Text) {
|
if item.Content != nil && includeRegex.MatchString(item.Content.Text) {
|
||||||
log.Printf("Excluded %#v\n", item)
|
log.Printf("Included %#v\n", item)
|
||||||
return nil
|
included = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if includeRegex.MatchString(item.Name) {
|
if includeRegex.MatchString(item.Name) {
|
||||||
log.Printf("Excluded %#v\n", item)
|
log.Printf("Included %#v\n", item)
|
||||||
return nil
|
included = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if included {
|
||||||
|
b.channelAddItem(conn, channelKey, item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,6 +417,12 @@ func (b *memoryBackend) channelAddItem(conn redis.Conn, channel string, item mic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return b.channelAddItem(conn, channel, item)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *memoryBackend) channelAddItem(conn redis.Conn, channel string, item microsub.Item) error {
|
||||||
|
zchannelKey := fmt.Sprintf("zchannel:%s:posts", channel)
|
||||||
|
|
||||||
if item.Published == "" {
|
if item.Published == "" {
|
||||||
item.Published = time.Now().Format(time.RFC3339)
|
item.Published = time.Now().Format(time.RFC3339)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user