|
@@ -97,7 +97,7 @@ func checkFeeds(feeds []rss.Feed) {
|
|
}
|
|
}
|
|
|
|
|
|
if feed.Unread != 0 {
|
|
if feed.Unread != 0 {
|
|
- notify(i, feed.Items[0])
|
|
|
|
|
|
+ notify(i, feed.Items[len(feed.Items)-1])
|
|
feed.Unread = 0
|
|
feed.Unread = 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -111,8 +111,9 @@ func notify(i int, item *rss.Item) {
|
|
cmd := exec.Command(Loaded[i].Hook)
|
|
cmd := exec.Command(Loaded[i].Hook)
|
|
err := cmd.Start()
|
|
err := cmd.Start()
|
|
if err != nil {
|
|
if err != nil {
|
|
- log.Fatalf("notify: Failed to start command: %s\n", err.Error())
|
|
|
|
|
|
+ log.Fatalf("notify: Failed to start command: %s\n", err.Error()) // TODO: retry?
|
|
}
|
|
}
|
|
|
|
+ // TODO: write outputs to files, and graceful shutdown
|
|
} else if Loaded[i].Method == "webhook" {
|
|
} else if Loaded[i].Method == "webhook" {
|
|
// We'll post the item as a JSON object.
|
|
// We'll post the item as a JSON object.
|
|
// So first of all encode it.
|
|
// So first of all encode it.
|
|
@@ -130,7 +131,7 @@ func notify(i int, item *rss.Item) {
|
|
|
|
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Printf("notify: Failed to POST to %s - %s\n",
|
|
log.Printf("notify: Failed to POST to %s - %s\n",
|
|
- Loaded[i].Hook, err.Error())
|
|
|
|
|
|
+ Loaded[i].Hook, err.Error()) // TODO: retry?
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -165,6 +166,7 @@ func main() {
|
|
flag.Parse()
|
|
flag.Parse()
|
|
|
|
|
|
// Setup the default timeout and TTL
|
|
// Setup the default timeout and TTL
|
|
|
|
+ // Remember that we respect spec, like `ttl` field in RSS 2.0
|
|
rss.DefaultRefreshInterval = 10 * time.Second
|
|
rss.DefaultRefreshInterval = 10 * time.Second
|
|
rss.DefaultFetchFunc = func(url string) (*http.Response, error) {
|
|
rss.DefaultFetchFunc = func(url string) (*http.Response, error) {
|
|
client := &http.Client{Timeout: *timeout}
|
|
client := &http.Client{Timeout: *timeout}
|
|
@@ -197,6 +199,7 @@ func main() {
|
|
ent.Url, err.Error())
|
|
ent.Url, err.Error())
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ // TODO: validiy checks (webhook/command)
|
|
// feed.Unread = 0
|
|
// feed.Unread = 0
|
|
feeds[i] = *feed
|
|
feeds[i] = *feed
|
|
}(i, ent)
|
|
}(i, ent)
|