all repos — honk @ ac0ed31df7c70b44be8b6c1037fa45b2cb472a03

my fork of honk

save timestamp for xonker additions
Ted Unangst tedu@tedunangst.com
Mon, 25 Nov 2019 15:50:17 -0500
commit

ac0ed31df7c70b44be8b6c1037fa45b2cb472a03

parent

3cd37d058cfd4b51c0d8fc470faabba9af050458

5 files changed, 18 insertions(+), 9 deletions(-)

jump to
M activity.goactivity.go

@@ -1317,7 +1317,8 @@ href, _ := l.GetString("href")

rel, _ := l.GetString("rel") t, _ := l.GetString("type") if rel == "self" && friendorfoe(t) { - _, err := stmtSaveXonker.Exec(name, href, "fishname") + when := time.Now().UTC().Format(dbtimeformat) + _, err := stmtSaveXonker.Exec(name, href, "fishname", when) if err != nil { log.Printf("error saving fishname: %s", err) }

@@ -1430,7 +1431,8 @@ if err != nil {

log.Printf("error decoding %s pubkey: %s", keyname, err) return } - _, err = stmtSaveXonker.Exec(keyname, data, "pubkey") + when := time.Now().UTC().Format(dbtimeformat) + _, err = stmtSaveXonker.Exec(keyname, data, "pubkey", when) if err != nil { log.Printf("error saving key: %s", err) }

@@ -1455,8 +1457,9 @@ inbox, _ := obj.GetString("inbox")

outbox, _ := obj.GetString("outbox") sbox, _ := obj.GetString("endpoints", "sharedInbox") if inbox != "" { + when := time.Now().UTC().Format(dbtimeformat) m := strings.Join([]string{inbox, outbox, sbox}, " ") - _, err = stmtSaveXonker.Exec(ident, m, "boxes") + _, err = stmtSaveXonker.Exec(ident, m, "boxes", when) if err != nil { log.Printf("error saving boxes: %s", err) }

@@ -1479,7 +1482,8 @@ return

} handle, _ = obj.GetString("preferredUsername") if handle != "" { - _, err = stmtSaveXonker.Exec(xid, handle, "handle") + when := time.Now().UTC().Format(dbtimeformat) + _, err = stmtSaveXonker.Exec(xid, handle, "handle", when) if err != nil { log.Printf("error saving handle: %s", err) }
M database.godatabase.go

@@ -760,8 +760,8 @@ stmtFindZonk = preparetodie(db, "select zonkerid from zonkers where userid = ? and name = ? and wherefore = 'zonk'")

stmtGetZonkers = preparetodie(db, "select zonkerid, name, wherefore from zonkers where userid = ? and wherefore <> 'zonk'") stmtSaveZonker = preparetodie(db, "insert into zonkers (userid, name, wherefore) values (?, ?, ?)") stmtGetXonker = preparetodie(db, "select info from xonkers where name = ? and flavor = ?") - stmtSaveXonker = preparetodie(db, "insert into xonkers (name, info, flavor) values (?, ?, ?)") - stmtDeleteXonker = preparetodie(db, "delete from xonkers where name = ? and flavor = ?") + stmtSaveXonker = preparetodie(db, "insert into xonkers (name, info, flavor, dt) values (?, ?, ?, ?)") + stmtDeleteXonker = preparetodie(db, "delete from xonkers where name = ? and flavor = ? and dt < ?") stmtRecentHonkers = preparetodie(db, "select distinct(honker) from honks where userid = ? and honker not in (select xid from honkers where userid = ? and flavor = 'sub') order by honkid desc limit 100") stmtUpdateFlags = preparetodie(db, "update honks set flags = flags | ? where honkid = ?") stmtClearFlags = preparetodie(db, "update honks set flags = flags & ~ ? where honkid = ?")
M schema.goschema.go

@@ -6,7 +6,7 @@ create table honks (honkid integer primary key, userid integer, what text, honker text, xid text, rid text, dt text, url text, audience text, noise text, convoy text, whofore integer, format text, precis text, oonker text, flags integer);

create table donks (honkid integer, fileid integer); create table filemeta (fileid integer primary key, xid text, name text, description text, url text, media text, local integer); create table honkers (honkerid integer primary key, userid integer, name text, xid text, flavor text, combos text, owner text); -create table xonkers (xonkerid integer primary key, name text, info text, flavor text); +create table xonkers (xonkerid integer primary key, name text, info text, flavor text, dt text); create table zonkers (zonkerid integer primary key, userid integer, name text, wherefore text); create table doovers(dooverid integer primary key, dt text, tries integer, userid integer, rcpt text, msg blob); create table onts (ontology text, honkid integer);
M schema.sqlschema.sql

@@ -3,7 +3,7 @@ create table honks (honkid integer primary key, userid integer, what text, honker text, xid text, rid text, dt text, url text, audience text, noise text, convoy text, whofore integer, format text, precis text, oonker text, flags integer);

create table donks (honkid integer, fileid integer); create table filemeta (fileid integer primary key, xid text, name text, description text, url text, media text, local integer); create table honkers (honkerid integer primary key, userid integer, name text, xid text, flavor text, combos text, owner text); -create table xonkers (xonkerid integer primary key, name text, info text, flavor text); +create table xonkers (xonkerid integer primary key, name text, info text, flavor text, dt text); create table zonkers (zonkerid integer primary key, userid integer, name text, wherefore text); create table doovers(dooverid integer primary key, dt text, tries integer, userid integer, rcpt text, msg blob); create table onts (ontology text, honkid integer);
M upgradedb.goupgradedb.go

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

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

@@ -356,6 +356,11 @@ doordie(db, "create index idx_trackhonkid on tracks(xid)")

doordie(db, "update config set value = 32 where key = 'dbversion'") fallthrough case 32: + doordie(db, "alter table xonkers add column dt text") + doordie(db, "update xonkers set dt = ?", time.Now().UTC().Format(dbtimeformat)) + doordie(db, "update config set value = 33 where key = 'dbversion'") + fallthrough + case 33: default: log.Fatalf("can't upgrade unknown version %d", dbversion)