all repos — honk @ bafe9960d9cbc6fa533e8c91fed384ebe0d15962

my fork of honk

initial steps towards fetch tracking
Ted Unangst tedu@tedunangst.com
Fri, 08 Nov 2019 14:50:57 -0500
commit

bafe9960d9cbc6fa533e8c91fed384ebe0d15962

parent

3f9fb0dd66b48c2b0064c8777dce8e64195a5d3b

4 files changed, 19 insertions(+), 1 deletions(-)

jump to
M schema.goschema.go

@@ -12,6 +12,7 @@ create table doovers(dooverid integer primary key, dt text, tries integer, userid integer, rcpt text, msg blob);

create table onts (ontology text, honkid integer); create table honkmeta (honkid integer, genus text, json text); create table hfcs (hfcsid integer primary key, userid integer, json text); +create table tracks (xid text, fetches text); create index idx_honksxid on honks(xid); create index idx_honksconvoy on honks(convoy);

@@ -26,6 +27,7 @@ create index idx_ontology on onts(ontology);

create index idx_onthonkid on onts(honkid); create index idx_honkmetaid on honkmeta(honkid); create index idx_hfcsuser on hfcs(userid); +create index idx_trackhonkid on tracks(xid); create table config (key text, value text);
M schema.sqlschema.sql

@@ -9,6 +9,7 @@ create table doovers(dooverid integer primary key, dt text, tries integer, userid integer, rcpt text, msg blob);

create table onts (ontology text, honkid integer); create table honkmeta (honkid integer, genus text, json text); create table hfcs (hfcsid integer primary key, userid integer, json text); +create table tracks (xid text, fetches text); create index idx_honksxid on honks(xid); create index idx_honksconvoy on honks(convoy);

@@ -23,6 +24,7 @@ create index idx_ontology on onts(ontology);

create index idx_onthonkid on onts(honkid); create index idx_honkmetaid on honkmeta(honkid); create index idx_hfcsuser on hfcs(userid); +create index idx_trackhonkid on tracks(xid); create table config (key text, value text);
M upgradedb.goupgradedb.go

@@ -24,7 +24,7 @@ "strings"

"time" ) -var myVersion = 31 +var myVersion = 32 func doordie(db *sql.DB, s string, args ...interface{}) { _, err := db.Exec(s, args...)

@@ -351,6 +351,11 @@ }

doordie(db, "update config set value = 31 where key = 'dbversion'") fallthrough case 31: + doordie(db, "create table tracks (xid text, fetches text)") + doordie(db, "create index idx_trackhonkid on tracks(xid)") + doordie(db, "update config set value = 32 where key = 'dbversion'") + fallthrough + case 32: default: log.Fatalf("can't upgrade unknown version %d", dbversion)
M web.goweb.go

@@ -854,6 +854,14 @@ log.Print(err)

} } +func trackback(xid string, r *http.Request) { + agent := r.UserAgent() + who := originate(agent) + sig := r.Header.Get("Signature") + + log.Printf("(%s) fetched %s (%s)", who, xid, sig) +} + func showonehonk(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] user, err := butwhatabout(name)

@@ -870,6 +878,7 @@

if friendorfoe(r.Header.Get("Accept")) { j, ok := gimmejonk(xid) if ok { + trackback(xid, r) w.Header().Set("Content-Type", theonetruename) w.Write(j) } else {