m
Ted Unangst tedu@tedunangst.com
Sat, 05 Aug 2023 20:53:15 -0400
3 files changed,
11 insertions(+),
9 deletions(-)
M
database.go
→
database.go
@@ -1121,7 +1121,7 @@ tx, err := blobdb.Begin()
if err != nil { elog.Fatal(err) } - for xid, _ := range filexids { + for xid := range filexids { _, err = tx.Exec("delete from filedata where xid = ?", xid) if err != nil { elog.Fatal(err)
M
import.go
→
import.go
@@ -338,7 +338,7 @@ } `json:"tweet"`
} var tweets []*Tweet - fd, err := os.Open(source + "/tweet.js") + fd, err := os.Open(source + "/tweets.js") if err != nil { elog.Fatal(err) }@@ -372,11 +372,6 @@ log.Printf("importing %v tweets", len(tweets))
for _, t := range tweets { xid := fmt.Sprintf("%s/%s/%s", user.URL, honkSep, t.Tweet.IdStr) if havetwid(xid) { - continue - } - - if t.Tweet.FavoriteCount == "0" || t.Tweet.FavoriteCount == "" { - log.Printf("skipping, unworthy tweet") continue }
M
web.go
→
web.go
@@ -602,7 +602,7 @@ rows.Scan(&xid)
honkers = append(honkers, Honker{XID: xid}) } rows.Close() - for i, _ := range honkers { + for i := range honkers { _, honkers[i].Handle = handles(honkers[i].XID) } templinfo := getInfo(r)@@ -2560,6 +2560,9 @@ }
} func fiveoh(w http.ResponseWriter, r *http.Request) { + if !develMode { + return + } fd, err := os.OpenFile("violations.json", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) if err != nil { elog.Printf("error opening violations! %s", err)@@ -2606,7 +2609,11 @@ }
func addcspheaders(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Security-Policy", "default-src 'none'; script-src 'self'; connect-src 'self'; style-src 'self'; img-src 'self'; media-src 'self'; report-uri /csp-violation") + policy := "default-src 'none'; script-src 'self'; connect-src 'self'; style-src 'self'; img-src 'self'; media-src 'self'" + if develMode { + policy += "; report-uri /csp-violation" + } + w.Header().Set("Content-Security-Policy", policy) next.ServeHTTP(w, r) }) }