allow for custom user options in the database
This commit is contained in:
parent
a90e5f1766
commit
5e59b3ecef
5
honk.go
5
honk.go
|
@ -235,7 +235,8 @@ func showrss(w http.ResponseWriter, r *http.Request) {
|
|||
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 @@ func prepareStatements(db *sql.DB) {
|
|||
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")
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -102,6 +102,9 @@ func upgradedb() {
|
|||
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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue