Compare commits

...

2 Commits

Author SHA1 Message Date
41c079b871
Add more debug logging for WebSub
All checks were successful
the build was successful
2018-08-05 21:02:10 +02:00
d89dac6159
Check exclude regex on HTML as well 2018-08-05 21:01:55 +02:00
2 changed files with 16 additions and 3 deletions

View File

@ -199,12 +199,15 @@ func (h *hubIncomingBackend) run() error {
for {
select {
case <-ticker.C:
log.Println("Getting feeds for WebSub")
feeds := h.GetFeeds()
for _, feed := range feeds {
log.Printf("Looking at %s\n", feed.URL)
if feed.ResubscribeAt == 0 || time.Now().After(time.Unix(feed.ResubscribeAt, 0)) {
if feed.Callback == "" {
feed.Callback = fmt.Sprintf("%s/incoming/%d", os.Getenv("EKSTER_BASEURL"), feed.ID)
}
log.Printf("Send resubscribe for %s\n", feed.URL)
h.Subscribe(&feed)
}
}

View File

@ -641,6 +641,10 @@ func (b *memoryBackend) Fetch3(channel, fetchURL string) (*http.Response, error)
}
func (b *memoryBackend) channelAddItemWithMatcher(conn redis.Conn, channel string, item microsub.Item) error {
// an item is posted
// check for all channels as channel
// if regex matches item
// - add item to channel
for channelKey, setting := range b.Settings {
if setting.IncludeRegex != "" {
included := false
@ -671,9 +675,15 @@ func (b *memoryBackend) channelAddItemWithMatcher(conn redis.Conn, channel strin
if err != nil {
log.Printf("error in regexp: %q\n", excludeRegex)
} else {
if item.Content != nil && excludeRegex.MatchString(item.Content.Text) {
log.Printf("Excluded %#v\n", item)
return nil
if item.Content != nil {
if excludeRegex.MatchString(item.Content.Text) {
log.Printf("Excluded %#v\n", item)
return nil
}
if excludeRegex.MatchString(item.Content.HTML) {
log.Printf("Excluded %#v\n", item)
return nil
}
}
if excludeRegex.MatchString(item.Name) {