diff --git a/activity.go b/activity.go index 76a3325..27a69be 100644 --- a/activity.go +++ b/activity.go @@ -253,7 +253,7 @@ func savexonk(user *WhatAbout, x *Honk) { 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 diff --git a/docs/changelog.txt b/docs/changelog.txt index 1b83b83..f1c2fcc 100644 --- a/docs/changelog.txt +++ b/docs/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. diff --git a/honk.go b/honk.go index c058aa5..649e967 100644 --- a/honk.go +++ b/honk.go @@ -71,6 +71,7 @@ type Honk struct { Audience []string Public bool Whofore int64 + Flags int64 HTML template.HTML Style string Open string @@ -740,7 +741,7 @@ func getxonk(userid int64, xid string) *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 @@ func getsomehonks(rows *sql.Rows, err error) []*Honk { 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 @@ func savebonk(w http.ResponseWriter, r *http.Request) { 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 @@ func savehonk(w http.ResponseWriter, r *http.Request) { 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 @@ func prepareStatements(db *sql.DB) { 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 @@ func prepareStatements(db *sql.DB) { 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 (?, ?)") diff --git a/schema.sql b/schema.sql index f4683b7..3bb863f 100644 --- a/schema.sql +++ b/schema.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); diff --git a/upgradedb.go b/upgradedb.go index 5ed7096..c1f0a5e 100644 --- a/upgradedb.go +++ b/upgradedb.go @@ -115,6 +115,11 @@ func upgradedb() { 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) } diff --git a/util.go b/util.go index 429d4e1..0d41359 100644 --- a/util.go +++ b/util.go @@ -72,7 +72,7 @@ var dbtimeformat = "2006-01-02 15:04:05" 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")