diff --git a/cmd/eksterd/fetch.go b/cmd/eksterd/fetch.go index f2bbfab..6c0f844 100644 --- a/cmd/eksterd/fetch.go +++ b/cmd/eksterd/fetch.go @@ -376,8 +376,24 @@ func (b *memoryBackend) Fetch3(channel, fetchURL string) (*http.Response, error) func (b *memoryBackend) channelAddItem(conn redis.Conn, channel string, item microsub.Item) error { zchannelKey := fmt.Sprintf("zchannel:%s:posts", channel) - var excludeRegex regexp.Regexp - testExcludeRegex := false + for _, setting := range b.Settings { + if setting.IncludeRegex != "" { + includeRegex, err := regexp.Compile(setting.IncludeRegex) + if err != nil { + log.Printf("error in regexp: %q\n", includeRegex) + } else { + if item.Content != nil && includeRegex.MatchString(item.Content.Text) { + log.Printf("Excluded %#v\n", item) + return nil + } + + if includeRegex.MatchString(item.Name) { + log.Printf("Excluded %#v\n", item) + return nil + } + } + } + } if setting, e := b.Settings[channel]; e { if setting.ExcludeRegex != "" { @@ -385,23 +401,19 @@ func (b *memoryBackend) channelAddItem(conn redis.Conn, channel string, item mic if err != nil { log.Printf("error in regexp: %q\n", excludeRegex) } else { - testExcludeRegex = true + if item.Content != nil && excludeRegex.MatchString(item.Content.Text) { + log.Printf("Excluded %#v\n", item) + return nil + } + + if excludeRegex.MatchString(item.Name) { + log.Printf("Excluded %#v\n", item) + return nil + } } } } - if testExcludeRegex { - if item.Content != nil && excludeRegex.MatchString(item.Content.Text) { - log.Printf("Excluded %#v\n", item) - return nil - } - - if excludeRegex.MatchString(item.Name) { - log.Printf("Excluded %#v\n", item) - return nil - } - } - if item.Published == "" { item.Published = time.Now().Format(time.RFC3339) } diff --git a/cmd/eksterd/memory.go b/cmd/eksterd/memory.go index 56c7b99..f5f961e 100644 --- a/cmd/eksterd/memory.go +++ b/cmd/eksterd/memory.go @@ -48,6 +48,7 @@ type memoryBackend struct { type channelSetting struct { ExcludeRegex string + IncludeRegex string } type Debug interface { diff --git a/templates/channel.html b/templates/channel.html index 6332864..c8f623c 100644 --- a/templates/channel.html +++ b/templates/channel.html @@ -57,10 +57,16 @@
- +
+
+
+ + +
+