all repos — honk @ 9fd970ce7e1b1de5018279892bb6bbb3e9260a25

my fork of honk

allow for custom user options in the database
Ted Unangst tedu@tedunangst.com
Thu, 27 Jun 2019 22:15:59 -0400
commit

9fd970ce7e1b1de5018279892bb6bbb3e9260a25

parent

78893c4f071e7fb8be25c0eacbc83c3369ce7ad8

4 files changed, 8 insertions(+), 4 deletions(-)

jump to
M honk.gohonk.go

@@ -235,7 +235,8 @@

func butwhatabout(name string) (*WhatAbout, error) { row := stmtWhatAbout.QueryRow(name) var user WhatAbout - err := row.Scan(&user.ID, &user.Name, &user.Display, &user.About, &user.Key) + var options string + err := row.Scan(&user.ID, &user.Name, &user.Display, &user.About, &user.Key, &options) user.URL = fmt.Sprintf("https://%s/u/%s", serverName, user.Name) return &user, err }

@@ -1525,7 +1526,7 @@ stmtZonkIt = preparetodie(db, "delete from honks where userid = ? and xid = ?")

stmtZonkDonks = preparetodie(db, "delete from donks where honkid = ?") stmtFindFile = preparetodie(db, "select fileid from files where url = ? and local = 1") stmtSaveFile = preparetodie(db, "insert into files (xid, name, url, media, local, content) values (?, ?, ?, ?, ?, ?)") - stmtWhatAbout = preparetodie(db, "select userid, username, displayname, about, pubkey from users where username = ?") + stmtWhatAbout = preparetodie(db, "select userid, username, displayname, about, pubkey, options from users where username = ?") stmtSaveDub = preparetodie(db, "insert into honkers (userid, name, xid, flavor) values (?, ?, ?, ?)") stmtAddDoover = preparetodie(db, "insert into doovers (dt, tries, username, rcpt, msg) values (?, ?, ?, ?, ?)") stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers")
M schema.sqlschema.sql

@@ -18,7 +18,7 @@ create index idx_filesurl on files(url);

create table config (key text, value text); -create table users (userid integer primary key, username text, hash text, displayname text, about text, pubkey text, seckey text); +create table users (userid integer primary key, username text, hash text, displayname text, about text, pubkey text, seckey text, options text); create table auth (authid integer primary key, userid integer, hash text); CREATE index idxusers_username on users(username); CREATE index idxauth_userid on auth(userid);
M upgradedb.goupgradedb.go

@@ -102,6 +102,9 @@ doordie(db, "update zonkers set wherefore = 'zomain' where wherefore = 'zurl'")

doordie(db, "update zonkers set wherefore = 'zord' where wherefore = 'zword'") doordie(db, "update config set value = 11 where key = 'dbversion'") case 11: + doordie(db, "alter table users add column options text") + doordie(db, "update users set options = ''") + doordie(db, "update config set value = 12 where key = 'dbversion'") default: log.Fatalf("can't upgrade unknown version %d", dbversion) }
M util.goutil.go

@@ -71,7 +71,7 @@

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