chore: assorted fixes

This commit is contained in:
xuu 2025-04-07 13:11:09 -06:00
parent be614cb67e
commit 09eba5dae8
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()
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)
if err != nil {
@ -548,8 +554,8 @@ func (n *TwtTime) Scan(value any) error {
n.Time, n.Valid = time.Time{}, false
return nil
case string:
n.Valid = true
n.Time, err = time.Parse(time.RFC3339, value)
n.Valid = err == nil
case time.Time:
n.Valid = true
n.Time = value

View File

@ -74,6 +74,7 @@ func NewHTTPFetcher() *httpFetcher {
ForceAttemptHTTP2: false,
MaxIdleConns: 100,
IdleConnTimeout: 10 * time.Second,
ResponseHeaderTimeout: 5 * time.Second,
TLSHandshakeTimeout: 5 * 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")
hash := r.PathValue("hash")
if (len(hash) < 6 || len(hash) > 8) && !notAny(hash, "abcdefghijklmnopqrstuvwxyz234567") {
w.WriteHeader(http.StatusBadRequest)
return
}
// if (len(hash) < 6 || len(hash) > 8) && !notAny(hash, "abcdefghijklmnopqrstuvwxyz234567") {
// w.WriteHeader(http.StatusBadRequest)
// return
// }
limit := 100
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,
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,
"/conv/"+subject,
twt,
)
output += int64(i)

View File

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