If the item content matches my website, also add it to noficitations
This commit is contained in:
parent
10bce8189b
commit
6467d35529
|
@ -29,6 +29,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"regexp"
|
||||||
"rss"
|
"rss"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -323,6 +324,8 @@ func (b *memoryBackend) feedItems(fetchURL, contentType string, body io.Reader)
|
||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var nameRegex *regexp.Regexp = regexp.MustCompile(`(?i:pstuifzand|peter|stuifzand|peter\s*stuifzand|p83\.nl|publog\.stuifzandapp\.com)`)
|
||||||
|
|
||||||
func (b *memoryBackend) ProcessContent(channel, fetchURL, contentType string, body io.Reader) error {
|
func (b *memoryBackend) ProcessContent(channel, fetchURL, contentType string, body io.Reader) error {
|
||||||
items, err := b.feedItems(fetchURL, contentType, body)
|
items, err := b.feedItems(fetchURL, contentType, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -332,6 +335,11 @@ func (b *memoryBackend) ProcessContent(channel, fetchURL, contentType string, bo
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
item.Read = false
|
item.Read = false
|
||||||
b.channelAddItem(channel, item)
|
b.channelAddItem(channel, item)
|
||||||
|
|
||||||
|
// Add items to notifications that match my name and websites
|
||||||
|
if len(item.Content.Text) > 0 && nameRegex.MatchString(item.Content.Text) {
|
||||||
|
b.channelAddItem("notifications", item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user