allow for custom user options in the database
Ted Unangst tedu@tedunangst.com
Thu, 27 Jun 2019 22:15:59 -0400
4 files changed,
8 insertions(+),
4 deletions(-)
M
honk.go
→
honk.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.sql
→
schema.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.go
→
upgradedb.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) }