chore: assorted fixes

This commit is contained in:
xuu 2025-04-07 13:11:09 -06:00
parent be614cb67e
commit e54869e4a1
Signed by: xuu
GPG Key ID: 8B3B0604F164E04F
5 changed files with 16 additions and 9 deletions

10
feed.go
View File

@ -237,7 +237,13 @@ func storeFeed(ctx context.Context, db db, f types.TwtFile) error {
loadTS := time.Now() loadTS := time.Now()
refreshRate := 600 refreshRate := 600
feedID := uuid.UrlNS.UUID5(cmp.Or(f.Twter().HashingURI, f.Twter().URI)) feedURI, _ := f.Info().GetN("uri", 0)
feedID := uuid.UrlNS.UUID5(cmp.Or(
feedURI.Value(),
f.Twter().HashingURI,
f.Twter().URI,
))
tx, err := db.BeginTx(ctx, nil) tx, err := db.BeginTx(ctx, nil)
if err != nil { if err != nil {
@ -548,8 +554,8 @@ func (n *TwtTime) Scan(value any) error {
n.Time, n.Valid = time.Time{}, false n.Time, n.Valid = time.Time{}, false
return nil return nil
case string: case string:
n.Valid = true
n.Time, err = time.Parse(time.RFC3339, value) n.Time, err = time.Parse(time.RFC3339, value)
n.Valid = err == nil
case time.Time: case time.Time:
n.Valid = true n.Valid = true
n.Time = value n.Time = value

View File

@ -74,6 +74,7 @@ func NewHTTPFetcher() *httpFetcher {
ForceAttemptHTTP2: false, ForceAttemptHTTP2: false,
MaxIdleConns: 100, MaxIdleConns: 100,
IdleConnTimeout: 10 * time.Second, IdleConnTimeout: 10 * time.Second,
ResponseHeaderTimeout: 5 * time.Second,
TLSHandshakeTimeout: 5 * time.Second, TLSHandshakeTimeout: 5 * time.Second,
ExpectContinueTimeout: 1 * time.Second, ExpectContinueTimeout: 1 * time.Second,
}, },

View File

@ -32,10 +32,10 @@ func (a *API) conv(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8") w.Header().Set("Content-Type", "text/plain; charset=utf-8")
hash := r.PathValue("hash") hash := r.PathValue("hash")
if (len(hash) < 6 || len(hash) > 8) && !notAny(hash, "abcdefghijklmnopqrstuvwxyz234567") { // if (len(hash) < 6 || len(hash) > 8) && !notAny(hash, "abcdefghijklmnopqrstuvwxyz234567") {
w.WriteHeader(http.StatusBadRequest) // w.WriteHeader(http.StatusBadRequest)
return // return
} // }
limit := 100 limit := 100
if v, ok := strconv.Atoi(r.URL.Query().Get("limit")); ok == nil { if v, ok := strconv.Atoi(r.URL.Query().Get("limit")); ok == nil {

View File

@ -222,7 +222,7 @@ func (r *HTWriter) WriteTo(w io.Writer) (int64, error) {
"/?uri="+twter.URI, twter.Nick, "/?uri="+twter.URI, twter.Nick,
twter.URI, uri.Host, twter.URI, uri.Host,
"/conv/"+subject, fmt.Sprintf("<time datetime='%s'>%s</time>", twt.Created().Format(time.RFC3339), twt.Created().Format(time.RFC822)), "/conv/"+subject, fmt.Sprintf("<time datetime='%s'>%s</time>", twt.Created().Format(time.RFC3339), twt.Created().Format(time.RFC822)),
"/conv/"+subject, "/conv/"+subject,
twt, twt,
) )
output += int64(i) output += int64(i)

View File

@ -30,8 +30,8 @@ func httpServer(ctx context.Context, app *appState) error {
} }
html := HTML{ html := HTML{
app: app, app: app,
db: db, db: db,
hostname: app.args.Hostname, hostname: app.args.Hostname,
} }