chore: refactor
This commit is contained in:
14
feed.go
14
feed.go
@@ -134,6 +134,10 @@ var (
|
||||
'+'||abs(refresh_rate+cast(random()%30 as int))||' seconds'
|
||||
) < datetime(current_timestamp, '+3 minutes')
|
||||
`
|
||||
permaban = []string{
|
||||
"//lublin.se/",
|
||||
"//enotty.dk/",
|
||||
}
|
||||
)
|
||||
|
||||
func (f *Feed) Create(ctx context.Context, db db) error {
|
||||
@@ -370,11 +374,10 @@ func storeFeed(ctx context.Context, db db, f types.TwtFile) error {
|
||||
}
|
||||
|
||||
func (feed *Feed) MakeHTTPRequest(ctx context.Context) (*http.Request, error) {
|
||||
if strings.Contains(feed.URI, "lublin.se") {
|
||||
return nil, fmt.Errorf("%w: permaban: %s", ErrPermanentlyDead, feed.URI)
|
||||
}
|
||||
if strings.Contains(feed.URI, "enotty.dk") {
|
||||
return nil, fmt.Errorf("%w: permaban: %s", ErrPermanentlyDead, feed.URI)
|
||||
for _, host := range permaban {
|
||||
if strings.Contains(feed.URI, host) {
|
||||
return nil, fmt.Errorf("%w: permaban: %s", ErrPermanentlyDead, feed.URI)
|
||||
}
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", feed.URI, nil)
|
||||
@@ -392,6 +395,7 @@ func (feed *Feed) MakeHTTPRequest(ctx context.Context) (*http.Request, error) {
|
||||
req.Header.Add("If-None-Match", feed.ETag.String)
|
||||
}
|
||||
|
||||
// TODO: this is probably not needed.
|
||||
if feed.DiscloseFeedURL != "" && feed.DiscloseNick != "" {
|
||||
req.Header.Set("User-Agent", fmt.Sprintf("xt/%s (+%s; @%s)",
|
||||
feed.Version, feed.DiscloseFeedURL, feed.DiscloseNick))
|
||||
|
||||
Reference in New Issue
Block a user