Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Commit

Permalink
fix: delete detected no longer feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
piraces committed Feb 3, 2023
1 parent 1068e45 commit bc6164e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/rsslay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (r *Relay) Init() error {
parsedFeed, err := feed.ParseFeed(entity.URL)
if err != nil {
log.Printf("failed to parse feed at url %q: %v", entity.URL, err)
feed.DeleteInvalidFeed(entity.URL, r.db)
continue
}

Expand Down Expand Up @@ -212,6 +213,7 @@ func (b store) QueryEvents(filter *nostr.Filter) ([]nostr.Event, error) {
parsedFeed, err := feed.ParseFeed(entity.URL)
if err != nil {
log.Printf("failed to parse feed at url %q: %v", entity.URL, err)
feed.DeleteInvalidFeed(entity.URL, relayInstance.db)
continue
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/feed/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package feed
import (
"crypto/hmac"
"crypto/sha256"
"database/sql"
"encoding/hex"
"encoding/json"
"fmt"
"github.com/piraces/rsslay/pkg/helpers"
"log"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -209,3 +211,11 @@ func PrivateKeyFromFeed(url string, secret string) string {
r := m.Sum(nil)
return hex.EncodeToString(r)
}

func DeleteInvalidFeed(url string, db *sql.DB) {
if _, err := db.Exec(`DELETE FROM feeds WHERE url=?`, url); err != nil {
log.Printf("failure to delete invalid feed: " + err.Error())
} else {
log.Printf("deleted invalid feed with url %q", url)
}
}

0 comments on commit bc6164e

Please sign in to comment.