all repos — honk @ f592ea42a831899ec563d9d45d41b6915a90513b

my fork of honk

schema change to add flags to honks
Ted Unangst tedu@tedunangst.com
Fri, 16 Aug 2019 15:13:33 -0400
commit

f592ea42a831899ec563d9d45d41b6915a90513b

parent

a67ca621a77629311266e129be088d5eaec5b7b1

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

jump to
M activity.goactivity.go

@@ -253,7 +253,7 @@ if strings.Contains(aud, user.URL) {

whofore = 1 } res, err := stmtSaveHonk.Exec(x.UserID, x.What, x.Honker, x.XID, x.RID, dt, x.URL, aud, - x.Noise, x.Convoy, whofore, "html", x.Precis, x.Oonker) + x.Noise, x.Convoy, whofore, "html", x.Precis, x.Oonker, 0) if err != nil { log.Printf("err saving xonk: %s", err) return
M docs/changelog.txtdocs/changelog.txt

@@ -2,6 +2,8 @@ changelog

-- next ++ Schema change. (add flags to honks table) + + Better understanding of ActivityPub Persons. No need to enter names! + More robust retries for fetching objects.
M honk.gohonk.go

@@ -71,6 +71,7 @@ Convoy string

Audience []string Public bool Whofore int64 + Flags int64 HTML template.HTML Style string Open string

@@ -740,7 +741,7 @@ h := new(Honk)

var dt, aud string row := stmtOneXonk.QueryRow(userid, xid) err := row.Scan(&h.ID, &h.UserID, &h.Username, &h.What, &h.Honker, &h.Oonker, &h.XID, &h.RID, - &dt, &h.URL, &aud, &h.Noise, &h.Precis, &h.Convoy, &h.Whofore) + &dt, &h.URL, &aud, &h.Noise, &h.Precis, &h.Convoy, &h.Whofore, &h.Flags) if err != nil { if err != sql.ErrNoRows { log.Printf("error scanning xonk: %s", err)

@@ -810,7 +811,7 @@ for rows.Next() {

var h Honk var dt, aud string err = rows.Scan(&h.ID, &h.UserID, &h.Username, &h.What, &h.Honker, &h.Oonker, - &h.XID, &h.RID, &dt, &h.URL, &aud, &h.Noise, &h.Precis, &h.Convoy, &h.Whofore) + &h.XID, &h.RID, &dt, &h.URL, &aud, &h.Noise, &h.Precis, &h.Convoy, &h.Whofore, &h.Flags) if err != nil { log.Printf("error scanning honks: %s", err) return nil

@@ -891,7 +892,7 @@ aud := strings.Join(bonk.Audience, " ")

whofore := 2 res, err := stmtSaveHonk.Exec(userinfo.UserID, "bonk", bonk.Honker, xid, "", dt.Format(dbtimeformat), "", aud, xonk.Noise, xonk.Convoy, whofore, "html", - xonk.Precis, oonker) + xonk.Precis, oonker, 0) if err != nil { log.Printf("error saving bonk: %s", err) return

@@ -1133,7 +1134,8 @@ }

return } res, err := stmtSaveHonk.Exec(userinfo.UserID, what, honk.Honker, xid, rid, - dt.Format(dbtimeformat), "", aud, honk.Noise, convoy, whofore, "html", honk.Precis, honk.Oonker) + dt.Format(dbtimeformat), "", aud, honk.Noise, convoy, whofore, "html", + honk.Precis, honk.Oonker, 0) if err != nil { log.Printf("error saving honk: %s", err) http.Error(w, "something bad happened while saving", http.StatusInternalServerError)

@@ -1601,7 +1603,7 @@ stmtUpdateCombos = preparetodie(db, "update honkers set combos = ? where honkerid = ? and userid = ?")

stmtHasHonker = preparetodie(db, "select honkerid from honkers where xid = ? and userid = ?") stmtDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and flavor = 'dub'") - selecthonks := "select honkid, honks.userid, username, what, honker, oonker, honks.xid, rid, dt, url, audience, noise, precis, convoy, whofore from honks join users on honks.userid = users.userid " + selecthonks := "select honkid, honks.userid, username, what, honker, oonker, honks.xid, rid, dt, url, audience, noise, precis, convoy, whofore, flags from honks join users on honks.userid = users.userid " limit := " order by honkid desc limit 250" butnotthose := " and convoy not in (select name from zonkers where userid = ? and wherefore = 'zonvoy' order by zonkerid desc limit 100)" stmtOneXonk = preparetodie(db, selecthonks+"where honks.userid = ? and xid = ?")

@@ -1614,7 +1616,7 @@ stmtHonksByXonker = preparetodie(db, selecthonks+" where honks.userid = ? and (honker = ? or oonker = ?)"+butnotthose+limit)

stmtHonksByCombo = preparetodie(db, selecthonks+"join honkers on honkers.xid = honks.honker where honks.userid = ? and honkers.combos like ?"+butnotthose+limit) stmtHonksByConvoy = preparetodie(db, selecthonks+"where (honks.userid = ? or (? = -1 and whofore = 2)) and convoy = ?"+limit) - stmtSaveHonk = preparetodie(db, "insert into honks (userid, what, honker, xid, rid, dt, url, audience, noise, convoy, whofore, format, precis, oonker) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") + stmtSaveHonk = preparetodie(db, "insert into honks (userid, what, honker, xid, rid, dt, url, audience, noise, convoy, whofore, format, precis, oonker, flags) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") stmtFileData = preparetodie(db, "select media, content from files where xid = ?") stmtFindXonk = preparetodie(db, "select honkid from honks where userid = ? and xid = ?") stmtSaveDonk = preparetodie(db, "insert into donks (honkid, fileid) values (?, ?)")
M schema.sqlschema.sql

@@ -1,5 +1,5 @@

-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); +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 files(fileid integer primary key, xid text, name text, url text, media text, local integer, content blob); create table honkers (honkerid integer primary key, userid integer, name text, xid text, flavor text, combos text);
M upgradedb.goupgradedb.go

@@ -115,6 +115,11 @@ doordie(db, "create index idx_honksoonker on honks(oonker)")

doordie(db, "update config set value = 13 where key = 'dbversion'") fallthrough case 13: + doordie(db, "alter table honks add column flags integer") + doordie(db, "update honks set flags = 0") + doordie(db, "update config set value = 14 where key = 'dbversion'") + fallthrough + case 14: default: log.Fatalf("can't upgrade unknown version %d", dbversion) }
M util.goutil.go

@@ -72,7 +72,7 @@

var alreadyopendb *sql.DB var dbname = "honk.db" var stmtConfig *sql.Stmt -var myVersion = 13 +var myVersion = 14 func initdb() { schema, err := ioutil.ReadFile("schema.sql")