Skip to content

Commit

Permalink
feat(web): add count parameter to rss feed
Browse files Browse the repository at this point in the history
  • Loading branch information
tgragnato committed Nov 27, 2024
1 parent 260d8ae commit e929024
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion web/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/xml"
"fmt"
"net/http"
"strconv"
"time"

"tgragnato.it/magnetico/persistence"
Expand Down Expand Up @@ -42,6 +43,13 @@ func feedHandler(w http.ResponseWriter, r *http.Request) {
return
}

count := uint64(20)
if len(r.URL.Query()["count"]) == 1 {
if i, err := strconv.Atoi(r.URL.Query()["count"][0]); err == nil {
count = uint64(i)

Check failure on line 49 in web/feed.go

View workflow job for this annotation

GitHub Actions / Build (1.22)

G115: integer overflow conversion int -> uint64 (gosec)
}
}

if query == "" {
title = "Most recent torrents - magnetico"
} else {
Expand All @@ -53,7 +61,7 @@ func feedHandler(w http.ResponseWriter, r *http.Request) {
time.Now().Unix(),
persistence.ByDiscoveredOn,
true,
20,
count,
nil,
nil,
)
Expand Down

0 comments on commit e929024

Please sign in to comment.