repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
adb600b
parent
a12b0a3
author
Eric Bower
date
2023-01-24 20:56:42 +0000 UTC
fix(feeds): support reddit rss feeds
1 files changed,  +9, -2
M feeds/cron.go
+9, -2
 1@@ -1,6 +1,7 @@
 2 package feeds
 3 
 4 import (
 5+	"crypto/tls"
 6 	"errors"
 7 	"fmt"
 8 	html "html/template"
 9@@ -19,12 +20,14 @@ import (
10 
11 var ErrNoRecentArticles = errors.New("no recent articles")
12 
13+var userAgent = "linux:feeds:v2"
14+
15 type UserAgentTransport struct {
16 	http.RoundTripper
17 }
18 
19 func (c *UserAgentTransport) RoundTrip(r *http.Request) (*http.Response, error) {
20-	r.Header.Set("User-Agent", "linux:feeds:v1")
21+	r.Header.Set("User-Agent", userAgent)
22 	return c.RoundTripper.RoundTrip(r)
23 }
24 
25@@ -164,7 +167,11 @@ func (f *Fetcher) RunUser(user *db.User) error {
26 
27 func (f *Fetcher) ParseURL(fp *gofeed.Parser, url string) (*gofeed.Feed, error) {
28 	client := &http.Client{
29-		Transport: &UserAgentTransport{http.DefaultTransport},
30+		Transport: &UserAgentTransport{
31+			&http.Transport{
32+				TLSClientConfig: &tls.Config{},
33+			},
34+		},
35 	}
36 
37 	req, err := http.NewRequest("GET", url, nil)