Paywall signal detection, sqlite driver registration, /img route fix
- Detect explicit paywall markers (article:content_tier meta, JSON-LD
isAccessibleForFree) so metered articles fall back to Wayback even
when body length is above threshold
- Blank-import go.mau.fi/util/dbutil/litestream so the sqlite3-fk-wal
driver mautrix's cryptohelper depends on is registered
- Fix /img route: Go ServeMux requires {wildcard} to be a whole segment,
so capture {name} and strip the .avif suffix in the handler
This commit is contained in:
@@ -69,7 +69,7 @@ func New(cfg config.WebConfig) (*Server, error) {
|
||||
return nil, err
|
||||
}
|
||||
mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSub))))
|
||||
mux.HandleFunc("GET /img/{hash}.avif", s.handleImg)
|
||||
mux.HandleFunc("GET /img/{name}", s.handleImg)
|
||||
|
||||
mux.HandleFunc("GET /{$}", s.handleIndex)
|
||||
for _, ch := range channels {
|
||||
|
||||
@@ -56,7 +56,12 @@ func thumbURL(src string) string {
|
||||
}
|
||||
|
||||
func (s *Server) handleImg(w http.ResponseWriter, r *http.Request) {
|
||||
hash := r.PathValue("hash")
|
||||
name := r.PathValue("name")
|
||||
hash, ok := strings.CutSuffix(name, ".avif")
|
||||
if !ok {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
src := r.URL.Query().Get("u")
|
||||
if src == "" || thumbKey(src) != hash {
|
||||
http.NotFound(w, r)
|
||||
|
||||
Reference in New Issue
Block a user