all repos — honk @ 7a861c7dfa1d5f248a663564d56c77b9f069fefd

my fork of honk

replace int64 with userid type
Ted Unangst tedu@tedunangst.com
Thu, 29 Feb 2024 19:32:08 -0500
commit

7a861c7dfa1d5f248a663564d56c77b9f069fefd

parent

acaa0a80d56b16fe3127a13a4f143647992e8cf1

8 files changed, 132 insertions(+), 131 deletions(-)

jump to
M activity.goactivity.go

@@ -112,15 +112,15 @@ ilog.Printf("successful post: %s %d", url, resp.StatusCode)

return nil } -func GetJunk(userid int64, url string) (junk.Junk, error) { +func GetJunk(userid UserID, url string) (junk.Junk, error) { return GetJunkTimeout(userid, url, slowTimeout*time.Second, nil) } -func GetJunkFast(userid int64, url string) (junk.Junk, error) { +func GetJunkFast(userid UserID, url string) (junk.Junk, error) { return GetJunkTimeout(userid, url, fastTimeout*time.Second, nil) } -func GetJunkHardMode(userid int64, url string) (junk.Junk, error) { +func GetJunkHardMode(userid UserID, url string) (junk.Junk, error) { j, err := GetJunk(userid, url) if err != nil { emsg := err.Error()

@@ -141,7 +141,7 @@ }

var flightdeck = gate.NewSerializer() -func GetJunkTimeout(userid int64, url string, timeout time.Duration, final *string) (junk.Junk, error) { +func GetJunkTimeout(userid UserID, url string, timeout time.Duration, final *string) (junk.Junk, error) { if rejectorigin(userid, url, false) { return nil, fmt.Errorf("rejected origin: %s", url) }

@@ -333,7 +333,7 @@ donk.FileID = fileid

return donk } -func iszonked(userid int64, xid string) bool { +func iszonked(userid UserID, xid string) bool { var id int64 row := stmtFindZonk.QueryRow(userid, xid) err := row.Scan(&id)

@@ -385,7 +385,7 @@ }

return true } -func eradicatexonk(userid int64, xid string) { +func eradicatexonk(userid UserID, xid string) { xonk := getxonk(userid, xid) if xonk != nil { deletehonk(xonk.ID)
M database.godatabase.go

@@ -83,7 +83,7 @@ user.Onts = marker.HashTags

return user, true }}) -var somenumberedusers = gencache.New(gencache.Options[int64, *WhatAbout]{Fill: func(userid int64) (*WhatAbout, bool) { +var somenumberedusers = gencache.New(gencache.Options[UserID, *WhatAbout]{Fill: func(userid UserID) (*WhatAbout, bool) { row := stmtUserByNumber.QueryRow(userid) user, err := userfromrow(row) if err != nil {

@@ -110,9 +110,9 @@ }

return user, nil } -var honkerinvalidator gencache.Invalidator[int64] +var honkerinvalidator gencache.Invalidator[UserID] -func gethonkers(userid int64) []*Honker { +func gethonkers(userid UserID) []*Honker { rows, err := stmtHonkers.Query(userid) if err != nil { elog.Printf("error querying honkers: %s", err)

@@ -137,12 +137,12 @@ }

return honkers } -func getdubs(userid int64) []*Honker { +func getdubs(userid UserID) []*Honker { rows, err := stmtDubbers.Query(userid) return dubsfromrows(rows, err) } -func getnameddubs(userid int64, name string) []*Honker { +func getnameddubs(userid UserID, name string) []*Honker { rows, err := stmtNamedDubbers.Query(userid, name) return dubsfromrows(rows, err) }

@@ -178,7 +178,7 @@ }

return users } -func getxonk(userid int64, xid string) *Honk { +func getxonk(userid UserID, xid string) *Honk { if xid == "" { return nil }

@@ -186,7 +186,7 @@ row := stmtOneXonk.QueryRow(userid, xid, xid)

return scanhonk(row) } -func getbonk(userid int64, xid string) *Honk { +func getbonk(userid UserID, xid string) *Honk { row := stmtOneBonk.QueryRow(userid, xid) return scanhonk(row) }

@@ -196,7 +196,7 @@ dt := time.Now().Add(-honkwindow).UTC().Format(dbtimeformat)

rows, err := stmtPublicHonks.Query(dt, 100) return getsomehonks(rows, err) } -func geteventhonks(userid int64) []*Honk { +func geteventhonks(userid UserID) []*Honk { rows, err := stmtEventHonks.Query(userid, 25) honks := getsomehonks(rows, err) sort.Slice(honks, func(i, j int) bool {

@@ -237,23 +237,23 @@ }

rows, err := stmtUserHonks.Query(wanted, whofore, name, dt, limit) return getsomehonks(rows, err) } -func gethonksforuser(userid int64, wanted int64) []*Honk { +func gethonksforuser(userid UserID, wanted int64) []*Honk { dt := time.Now().Add(-honkwindow).UTC().Format(dbtimeformat) rows, err := stmtHonksForUser.Query(wanted, userid, dt, userid, userid) return getsomehonks(rows, err) } -func gethonksforuserfirstclass(userid int64, wanted int64) []*Honk { +func gethonksforuserfirstclass(userid UserID, wanted int64) []*Honk { dt := time.Now().Add(-honkwindow).UTC().Format(dbtimeformat) rows, err := stmtHonksForUserFirstClass.Query(wanted, userid, dt, userid, userid) return getsomehonks(rows, err) } -func gethonksforme(userid int64, wanted int64) []*Honk { +func gethonksforme(userid UserID, wanted int64) []*Honk { dt := time.Now().Add(-honkwindow).UTC().Format(dbtimeformat) rows, err := stmtHonksForMe.Query(wanted, userid, dt, userid, 250) return getsomehonks(rows, err) } -func gethonksfromlongago(userid int64, wanted int64) []*Honk { +func gethonksfromlongago(userid UserID, wanted int64) []*Honk { var params []interface{} var wheres []string params = append(params, wanted)

@@ -273,29 +273,29 @@ db := opendatabase()

rows, err := db.Query(sql, params...) return getsomehonks(rows, err) } -func getsavedhonks(userid int64, wanted int64) []*Honk { +func getsavedhonks(userid UserID, wanted int64) []*Honk { rows, err := stmtHonksISaved.Query(wanted, userid) return getsomehonks(rows, err) } -func gethonksbyhonker(userid int64, honker string, wanted int64) []*Honk { +func gethonksbyhonker(userid UserID, honker string, wanted int64) []*Honk { rows, err := stmtHonksByHonker.Query(wanted, userid, honker, userid) return getsomehonks(rows, err) } -func gethonksbyxonker(userid int64, xonker string, wanted int64) []*Honk { +func gethonksbyxonker(userid UserID, xonker string, wanted int64) []*Honk { rows, err := stmtHonksByXonker.Query(wanted, userid, xonker, xonker, userid) return getsomehonks(rows, err) } -func gethonksbycombo(userid int64, combo string, wanted int64) []*Honk { +func gethonksbycombo(userid UserID, combo string, wanted int64) []*Honk { combo = "% " + combo + " %" rows, err := stmtHonksByCombo.Query(wanted, userid, userid, combo, userid, wanted, userid, combo, userid) return getsomehonks(rows, err) } -func gethonksbyconvoy(userid int64, convoy string, wanted int64) []*Honk { +func gethonksbyconvoy(userid UserID, convoy string, wanted int64) []*Honk { rows, err := stmtHonksByConvoy.Query(wanted, userid, userid, convoy) honks := getsomehonks(rows, err) return honks } -func gethonksbysearch(userid int64, q string, wanted int64) []*Honk { +func gethonksbysearch(userid UserID, q string, wanted int64) []*Honk { var queries []string var params []interface{} queries = append(queries, "honks.honkid > ?")

@@ -368,7 +368,7 @@ rows, err := opendatabase().Query(selecthonks+where+butnotthose+limit, params...)

honks := getsomehonks(rows, err) return honks } -func gethonksbyontology(userid int64, name string, wanted int64) []*Honk { +func gethonksbyontology(userid UserID, name string, wanted int64) []*Honk { rows, err := stmtHonksByOntology.Query(wanted, name, userid, userid) honks := getsomehonks(rows, err) return honks

@@ -669,7 +669,7 @@ }

return err } -func chatplusone(tx *sql.Tx, userid int64) { +func chatplusone(tx *sql.Tx, userid UserID) { user, ok := somenumberedusers.Get(userid) if !ok { return

@@ -687,7 +687,7 @@ somenamedusers.Clear(user.Name)

somenumberedusers.Clear(user.ID) } -func chatnewnone(userid int64) { +func chatnewnone(userid UserID) { user, ok := somenumberedusers.Get(userid) if !ok || user.Options.ChatCount == 0 { return

@@ -706,7 +706,7 @@ somenamedusers.Clear(user.Name)

somenumberedusers.Clear(user.ID) } -func meplusone(tx *sql.Tx, userid int64) { +func meplusone(tx *sql.Tx, userid UserID) { user, ok := somenumberedusers.Get(userid) if !ok { return

@@ -724,7 +724,7 @@ somenamedusers.Clear(user.Name)

somenumberedusers.Clear(user.ID) } -func menewnone(userid int64) { +func menewnone(userid UserID) { user, ok := somenumberedusers.Get(userid) if !ok || user.Options.MeCount == 0 { return

@@ -743,7 +743,7 @@ somenamedusers.Clear(user.Name)

somenumberedusers.Clear(user.ID) } -func loadchatter(userid int64) []*Chatter { +func loadchatter(userid UserID) []*Chatter { duedt := time.Now().Add(-3 * 24 * time.Hour).UTC().Format(dbtimeformat) rows, err := stmtLoadChonks.Query(userid, duedt) if err != nil {
M deliverator.godeliverator.go

@@ -29,7 +29,7 @@

type Doover struct { ID int64 When time.Time - Userid int64 + Userid UserID Tries int64 Rcpt string Msgs [][]byte

@@ -84,7 +84,7 @@ }

var dqmtx sync.Mutex -func delinquent(userid int64, rcpt string, msg []byte) bool { +func delinquent(userid UserID, rcpt string, msg []byte) bool { dqmtx.Lock() defer dqmtx.Unlock() row := stmtDeliquentCheck.QueryRow(userid, rcpt)

@@ -108,7 +108,7 @@ }

return true } -func deliverate(userid int64, rcpt string, msg []byte) { +func deliverate(userid UserID, rcpt string, msg []byte) { if delinquent(userid, rcpt, msg) { return }
M fun.gofun.go

@@ -63,7 +63,7 @@ relingo[l] = v

} } -func reverbolate(userid int64, honks []*Honk) { +func reverbolate(userid UserID, honks []*Honk) { user, _ := somenumberedusers.Get(userid) for _, h := range honks { h.What += "ed"

@@ -524,7 +524,7 @@ }

var re_quickmention = regexp.MustCompile("(^|[ \n])@[[:alnum:]_]+([ \n:;.,']|$)") -func quickrename(s string, userid int64) string { +func quickrename(s string, userid UserID) string { nonstop := true for nonstop { nonstop = false

@@ -559,7 +559,7 @@ }

return s } -var shortnames = gencache.New(gencache.Options[int64, map[string]string]{Fill: func(userid int64) (map[string]string, bool) { +var shortnames = gencache.New(gencache.Options[UserID, map[string]string]{Fill: func(userid UserID) (map[string]string, bool) { honkers := gethonkers(userid) m := make(map[string]string) for _, h := range honkers {

@@ -568,7 +568,7 @@ }

return m, true }, Invalidator: &honkerinvalidator}) -func shortname(userid int64, xid string) string { +func shortname(userid UserID, xid string) string { m, ok := shortnames.Get(userid) if ok { return m[xid]

@@ -576,7 +576,7 @@ }

return "" } -var fullnames = gencache.New(gencache.Options[int64, map[string]string]{Fill: func(userid int64) (map[string]string, bool) { +var fullnames = gencache.New(gencache.Options[UserID, map[string]string]{Fill: func(userid UserID) (map[string]string, bool) { honkers := gethonkers(userid) m := make(map[string]string) for _, h := range honkers {

@@ -585,7 +585,7 @@ }

return m, true }, Invalidator: &honkerinvalidator}) -func fullname(name string, userid int64) string { +func fullname(name string, userid UserID) string { m, ok := fullnames.Get(userid) if ok { return m[name]

@@ -688,7 +688,7 @@ }

return a[:j] } -var ziggies = gencache.New(gencache.Options[int64, *KeyInfo]{Fill: func(userid int64) (*KeyInfo, bool) { +var ziggies = gencache.New(gencache.Options[UserID, *KeyInfo]{Fill: func(userid UserID) (*KeyInfo, bool) { user, ok := somenumberedusers.Get(userid) if !ok { return nil, false

@@ -699,7 +699,7 @@ ki.seckey = user.SecKey

return ki, true }}) -func ziggy(userid int64) *KeyInfo { +func ziggy(userid UserID) *KeyInfo { ki, _ := ziggies.Get(userid) return ki }
M hfcs.gohfcs.go

@@ -73,18 +73,18 @@ }

type afiltermap map[filtType][]*Filter -var filtInvalidator gencache.Invalidator[int64] -var filtcache *gencache.Cache[int64, afiltermap] +var filtInvalidator gencache.Invalidator[UserID] +var filtcache *gencache.Cache[UserID, afiltermap] func init() { // resolve init loop - filtcache = gencache.New(gencache.Options[int64, afiltermap]{ + filtcache = gencache.New(gencache.Options[UserID, afiltermap]{ Fill: filtcachefiller, Invalidator: &filtInvalidator, }) } -func filtcachefiller(userid int64) (afiltermap, bool) { +func filtcachefiller(userid UserID) (afiltermap, bool) { rows, err := stmtGetFilters.Query(userid) if err != nil { elog.Printf("error querying filters: %s", err)

@@ -183,12 +183,12 @@ }

return filtmap, true } -func filtcacheclear(userid int64, dur time.Duration) { +func filtcacheclear(userid UserID, dur time.Duration) { time.Sleep(dur + time.Second) filtInvalidator.Clear(userid) } -func getfilters(userid int64, scope filtType) []*Filter { +func getfilters(userid UserID, scope filtType) []*Filter { filtmap, ok := filtcache.Get(userid) if ok { return filtmap[scope]

@@ -200,7 +200,7 @@ type arejectmap map[string][]*Filter

var rejectAnyKey = "..." -var rejectcache = gencache.New(gencache.Options[int64, arejectmap]{Fill: func(userid int64) (arejectmap, bool) { +var rejectcache = gencache.New(gencache.Options[UserID, arejectmap]{Fill: func(userid UserID) (arejectmap, bool) { m := make(arejectmap) filts := getfilters(userid, filtReject) for _, f := range filts {

@@ -221,12 +221,12 @@ }

return m, true }, Invalidator: &filtInvalidator}) -func rejectfilters(userid int64, name string) []*Filter { +func rejectfilters(userid UserID, name string) []*Filter { m, _ := rejectcache.Get(userid) return m[name] } -func rejectorigin(userid int64, origin string, isannounce bool) bool { +func rejectorigin(userid UserID, origin string, isannounce bool) bool { if o := originate(origin); o != "" { origin = o }

@@ -247,7 +247,7 @@ }

return false } -func rejectactor(userid int64, actor string) bool { +func rejectactor(userid UserID, actor string) bool { filts := rejectfilters(userid, actor) for _, f := range filts { if f.IsAnnounce {

@@ -282,7 +282,7 @@ }

return false } -var knownknowns = gencache.New(gencache.Options[int64, map[string]bool]{Fill: func(userid int64) (map[string]bool, bool) { +var knownknowns = gencache.New(gencache.Options[UserID, map[string]bool]{Fill: func(userid UserID) (map[string]bool, bool) { m := make(map[string]bool) honkers := gethonkers(userid) for _, h := range honkers {

@@ -291,12 +291,12 @@ }

return m, true }, Invalidator: &honkerinvalidator}) -func unknownActor(userid int64, actor string) bool { +func unknownActor(userid UserID, actor string) bool { knowns, _ := knownknowns.Get(userid) return !knowns[actor] } -func stealthmode(userid int64, r *http.Request) bool { +func stealthmode(userid UserID, r *http.Request) bool { agent := requestActor(r) if agent != "" { fake := rejectorigin(userid, agent, false)

@@ -416,7 +416,7 @@ }

return false } -func unsee(honks []*Honk, userid int64) { +func unsee(honks []*Honk, userid UserID) { if userid != -1 { colfilts := getfilters(userid, filtCollapse) rwfilts := getfilters(userid, filtRewrite)

@@ -454,7 +454,7 @@ }

} } -var untagged = cache.New(cache.Options{Filler: func(userid int64) (map[string]bool, bool) { +var untagged = cache.New(cache.Options{Filler: func(userid UserID) (map[string]bool, bool) { rows, err := stmtUntagged.Query(userid) if err != nil { elog.Printf("error query untagged: %s", err)

@@ -480,7 +480,7 @@ }

return bad, true }}) -func osmosis(honks []*Honk, userid int64, withfilt bool) []*Honk { +func osmosis(honks []*Honk, userid UserID, withfilt bool) []*Honk { var badparents map[string]bool untagged.GetAndLock(userid, &badparents) j := 0

@@ -516,15 +516,15 @@ return honks

} func savehfcs(w http.ResponseWriter, r *http.Request) { - userinfo := login.GetUserInfo(r) + userid := UserID(login.GetUserInfo(r).UserID) itsok := r.FormValue("itsok") if itsok == "iforgiveyou" { hfcsid, _ := strconv.ParseInt(r.FormValue("hfcsid"), 10, 0) - _, err := stmtDeleteFilter.Exec(userinfo.UserID, hfcsid) + _, err := stmtDeleteFilter.Exec(userid, hfcsid) if err != nil { elog.Printf("error deleting filter: %s", err) } - filtInvalidator.Clear(userinfo.UserID) + filtInvalidator.Clear(userid) http.Redirect(w, r, "/hfcs", http.StatusSeeOther) return }

@@ -558,12 +558,12 @@ }

j, err := jsonify(filt) if err == nil { - _, err = stmtSaveFilter.Exec(userinfo.UserID, j) + _, err = stmtSaveFilter.Exec(userid, j) } if err != nil { elog.Printf("error saving filter: %s", err) } - filtInvalidator.Clear(userinfo.UserID) + filtInvalidator.Clear(userid) http.Redirect(w, r, "/hfcs", http.StatusSeeOther) }
M honk.gohonk.go

@@ -25,7 +25,7 @@ "humungus.tedunangst.com/r/webs/httpsig"

) type WhatAbout struct { - ID int64 + ID UserID Name string Display string About string

@@ -59,12 +59,14 @@ keyname string

seckey httpsig.PrivateKey } -const serverUID int64 = -2 -const readyLuserOne int64 = 1 +type UserID int64 + +const serverUID UserID = -2 +const readyLuserOne UserID = 1 type Honk struct { ID int64 - UserID int64 + UserID UserID Username string What string Honker string

@@ -108,7 +110,7 @@ }

type Chonk struct { ID int64 - UserID int64 + UserID UserID XID string Who string Target string

@@ -247,7 +249,7 @@ }

type Honker struct { ID int64 - UserID int64 + UserID UserID Name string XID string Handle string
M util.goutil.go

@@ -266,7 +266,7 @@ if err != nil {

elog.Print(err) return } - err = login.SetPassword(user.ID, pass) + err = login.SetPassword(int64(user.ID), pass) if err != nil { elog.Print(err) return
M web.goweb.go

@@ -100,7 +100,7 @@ }

if u := login.GetUserInfo(r); u != nil { templinfo["UserInfo"], _ = butwhatabout(u.Username) templinfo["UserStyle"] = getuserstyle(u) - combos, _ := combocache.Get(u.UserID) + combos, _ := combocache.Get(UserID(u.UserID)) templinfo["Combos"] = combos } return templinfo

@@ -110,7 +110,7 @@ var oldnews = gencache.New(gencache.Options[string, []byte]{

Fill: func(url string) ([]byte, bool) { templinfo := getInfo(nil) var honks []*Honk - var userid int64 = -1 + var userid UserID = -1 templinfo["ServerMessage"] = serverMsg switch url {

@@ -151,7 +151,7 @@ return

} templinfo := getInfo(r) var honks []*Honk - var userid int64 = -1 + var userid UserID = -1 templinfo["ServerMessage"] = serverMsg if u == nil || r.URL.Path == "/front" {

@@ -164,7 +164,7 @@ templinfo["ShowRSS"] = true

honks = getpublichonks() } } else { - userid = u.UserID + userid = UserID(u.UserID) switch r.URL.Path { case "/atme": templinfo["ServerMessage"] = "at me!"

@@ -634,13 +634,13 @@

func ximport(w http.ResponseWriter, r *http.Request) { u := login.GetUserInfo(r) xid := strings.TrimSpace(r.FormValue("q")) - xonk := getxonk(u.UserID, xid) + xonk := getxonk(UserID(u.UserID), xid) if xonk == nil { p, _ := investigate(xid) if p != nil { xid = p.XID } - j, err := GetJunk(u.UserID, xid) + j, err := GetJunk(UserID(u.UserID), xid) if err != nil { http.Error(w, "error getting external object", http.StatusInternalServerError) ilog.Printf("error getting external object: %s", err)

@@ -833,9 +833,9 @@ name := mux.Vars(r)["name"]

var honks []*Honk if name == "" { name = r.FormValue("xid") - honks = gethonksbyxonker(u.UserID, name, 0) + honks = gethonksbyxonker(UserID(u.UserID), name, 0) } else { - honks = gethonksbyhonker(u.UserID, name, 0) + honks = gethonksbyhonker(UserID(u.UserID), name, 0) } miniform := templates.Sprintf(`<form action="/submithonker" method="POST"> <input type="hidden" name="CSRF" value="%s">

@@ -854,8 +854,8 @@

func showcombo(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] u := login.GetUserInfo(r) - honks := gethonksbycombo(u.UserID, name, 0) - honks = osmosis(honks, u.UserID, true) + honks := gethonksbycombo(UserID(u.UserID), name, 0) + honks = osmosis(honks, UserID(u.UserID), true) templinfo := getInfo(r) templinfo["PageName"] = "combo" templinfo["PageArg"] = name

@@ -866,12 +866,12 @@ }

func showconvoy(w http.ResponseWriter, r *http.Request) { c := r.FormValue("c") u := login.GetUserInfo(r) - honks := gethonksbyconvoy(u.UserID, c, 0) + honks := gethonksbyconvoy(UserID(u.UserID), c, 0) templinfo := getInfo(r) if len(honks) > 0 { templinfo["TopHID"] = honks[0].ID } - honks = osmosis(honks, u.UserID, false) + honks = osmosis(honks, UserID(u.UserID), false) //reversehonks(honks) honks = threadsort(honks) templinfo["PageName"] = "convoy"

@@ -887,7 +887,7 @@ ximport(w, r)

return } u := login.GetUserInfo(r) - honks := gethonksbysearch(u.UserID, q, 0) + honks := gethonksbysearch(UserID(u.UserID), q, 0) templinfo := getInfo(r) templinfo["PageName"] = "search" templinfo["PageArg"] = q

@@ -898,9 +898,9 @@ }

func showontology(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] u := login.GetUserInfo(r) - var userid int64 = -1 + var userid UserID = -1 if u != nil { - userid = u.UserID + userid = UserID(u.UserID) } honks := gethonksbyontology(userid, "#"+name, 0) if friendorfoe(r.Header.Get("Accept")) {

@@ -941,9 +941,9 @@ }

func thelistingoftheontologies(w http.ResponseWriter, r *http.Request) { u := login.GetUserInfo(r) - var userid int64 = -1 + var userid UserID = -1 if u != nil { - userid = u.UserID + userid = UserID(u.UserID) } rows, err := stmtAllOnts.Query(userid) if err != nil {

@@ -1292,7 +1292,7 @@ http.NotFound(w, r)

return } u := login.GetUserInfo(r) - if u != nil && u.UserID != user.ID { + if u != nil && UserID(u.UserID) != user.ID { u = nil } if !honk.Public {

@@ -1336,9 +1336,9 @@ honkpage(w, u, honks, templinfo)

} func honkpage(w http.ResponseWriter, u *login.UserInfo, honks []*Honk, templinfo map[string]interface{}) { - var userid int64 = -1 + var userid UserID = -1 if u != nil { - userid = u.UserID + userid = UserID(u.UserID) templinfo["User"], _ = butwhatabout(u.Username) } reverbolate(userid, honks)

@@ -1414,7 +1414,7 @@ if err != nil {

elog.Printf("error bouting what: %s", err) } somenamedusers.Clear(u.Username) - somenumberedusers.Clear(u.UserID) + somenumberedusers.Clear(user.ID) oldjonkers.Clear(u.Username) if sendupdate {

@@ -1515,11 +1515,11 @@

func zonkit(w http.ResponseWriter, r *http.Request) { wherefore := r.FormValue("wherefore") what := r.FormValue("what") - userinfo := login.GetUserInfo(r) - user, _ := butwhatabout(userinfo.Username) + u := login.GetUserInfo(r) + user, _ := butwhatabout(u.Username) if wherefore == "save" { - xonk := getxonk(userinfo.UserID, what) + xonk := getxonk(user.ID, what) if xonk != nil { _, err := stmtUpdateFlags.Exec(flagIsSaved, xonk.ID) if err != nil {

@@ -1530,7 +1530,7 @@ return

} if wherefore == "unsave" { - xonk := getxonk(userinfo.UserID, what) + xonk := getxonk(user.ID, what) if xonk != nil { _, err := stmtClearFlags.Exec(flagIsSaved, xonk.ID) if err != nil {

@@ -1548,7 +1548,7 @@ }

if reaction == "none" { return } - xonk := getxonk(userinfo.UserID, what) + xonk := getxonk(user.ID, what) if xonk != nil { _, err := stmtUpdateFlags.Exec(flagIsReacted, xonk.ID) if err != nil {

@@ -1563,7 +1563,7 @@ // my hammer is too big, oh well

defer oldjonks.Flush() if wherefore == "ack" { - xonk := getxonk(userinfo.UserID, what) + xonk := getxonk(user.ID, what) if xonk != nil && !xonk.IsAcked() { _, err := stmtUpdateFlags.Exec(flagIsAcked, xonk.ID) if err != nil {

@@ -1575,7 +1575,7 @@ return

} if wherefore == "deack" { - xonk := getxonk(userinfo.UserID, what) + xonk := getxonk(user.ID, what) if xonk != nil && xonk.IsAcked() { _, err := stmtClearFlags.Exec(flagIsAcked, xonk.ID) if err != nil {

@@ -1587,16 +1587,15 @@ return

} if wherefore == "bonk" { - user, _ := butwhatabout(userinfo.Username) bonkit(what, user) return } if wherefore == "unbonk" { - xonk := getbonk(userinfo.UserID, what) + xonk := getbonk(user.ID, what) if xonk != nil { deletehonk(xonk.ID) - xonk = getxonk(userinfo.UserID, what) + xonk = getxonk(user.ID, what) _, err := stmtClearFlags.Exec(flagIsBonked, xonk.ID) if err != nil { elog.Printf("error unbonking: %s", err)

@@ -1607,7 +1606,7 @@ return

} if wherefore == "untag" { - xonk := getxonk(userinfo.UserID, what) + xonk := getxonk(user.ID, what) if xonk != nil { _, err := stmtUpdateFlags.Exec(flagIsUntagged, xonk.ID) if err != nil {

@@ -1615,7 +1614,7 @@ elog.Printf("error untagging: %s", err)

} } var badparents map[string]bool - untagged.GetAndLock(userinfo.UserID, &badparents) + untagged.GetAndLock(user.ID, &badparents) badparents[what] = true untagged.Unlock() return

@@ -1623,7 +1622,7 @@ }

ilog.Printf("zonking %s %s", wherefore, what) if wherefore == "zonk" { - xonk := getxonk(userinfo.UserID, what) + xonk := getxonk(user.ID, what) if xonk != nil { deletehonk(xonk.ID) if xonk.Whofore == 2 || xonk.Whofore == 3 {

@@ -1631,7 +1630,7 @@ sendzonkofsorts(xonk, user, "zonk", "")

} } } - _, err := stmtSaveZonker.Exec(userinfo.UserID, what, wherefore) + _, err := stmtSaveZonker.Exec(user.ID, what, wherefore) if err != nil { elog.Printf("error saving zonker: %s", err) return

@@ -1642,7 +1641,7 @@ func edithonkpage(w http.ResponseWriter, r *http.Request) {

u := login.GetUserInfo(r) user, _ := butwhatabout(u.Username) xid := r.FormValue("xid") - honk := getxonk(u.UserID, xid) + honk := getxonk(user.ID, xid) if !canedithonk(user, honk) { http.Error(w, "no editing that please", http.StatusInternalServerError) return

@@ -1655,7 +1654,7 @@ donksforhonks(honks)

for _, d := range honk.Donks { savedfiles = append(savedfiles, fmt.Sprintf("%s:%d", d.XID, d.FileID)) } - reverbolate(u.UserID, honks) + reverbolate(user.ID, honks) templinfo := getInfo(r) templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)

@@ -1691,7 +1690,7 @@ u := login.GetUserInfo(r)

rid := r.FormValue("rid") noise := "" - xonk := getxonk(u.UserID, rid) + xonk := getxonk(UserID(u.UserID), rid) if xonk != nil { _, replto := handles(xonk.Honker) if replto != "" {

@@ -1840,14 +1839,14 @@ http.Error(w, "unknown format", 500)

return nil } - userinfo := login.GetUserInfo(r) - user, _ := butwhatabout(userinfo.Username) + u := login.GetUserInfo(r) + user, _ := butwhatabout(u.Username) dt := time.Now().UTC() updatexid := r.FormValue("updatexid") var honk *Honk if updatexid != "" { - honk = getxonk(userinfo.UserID, updatexid) + honk = getxonk(user.ID, updatexid) if !canedithonk(user, honk) { http.Error(w, "no editing that please", http.StatusInternalServerError) return nil

@@ -1859,8 +1858,8 @@ } else {

xid := fmt.Sprintf("%s/%s/%s", user.URL, honkSep, xfiltrate()) what := "honk" honk = &Honk{ - UserID: userinfo.UserID, - Username: userinfo.Username, + UserID: user.ID, + Username: user.Name, What: what, Honker: user.URL, XID: xid,

@@ -1885,14 +1884,14 @@ }

return "" }) } - noise = quickrename(noise, userinfo.UserID) + noise = quickrename(noise, user.ID) honk.Noise = noise precipitate(honk) noise = honk.Noise translate(honk) if rid != "" { - xonk := getxonk(userinfo.UserID, rid) + xonk := getxonk(user.ID, rid) if xonk == nil { http.Error(w, "replyto disappeared", http.StatusNotFound) return nil

@@ -2024,11 +2023,11 @@ honk.Noise = noise

if r.FormValue("preview") == "preview" { honks := []*Honk{honk} - reverbolate(userinfo.UserID, honks) + reverbolate(user.ID, honks) templinfo := getInfo(r) templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) templinfo["Honks"] = honks - templinfo["MapLink"] = getmaplink(userinfo) + templinfo["MapLink"] = getmaplink(u) templinfo["InReplyTo"] = r.FormValue("rid") templinfo["Noise"] = r.FormValue("noise") templinfo["SavedFile"] = donkxid

@@ -2070,9 +2069,9 @@ return honk

} func showhonkers(w http.ResponseWriter, r *http.Request) { - userinfo := login.GetUserInfo(r) + userid := UserID(login.GetUserInfo(r).UserID) templinfo := getInfo(r) - templinfo["Honkers"] = gethonkers(userinfo.UserID) + templinfo["Honkers"] = gethonkers(userid) templinfo["HonkerCSRF"] = login.GetCSRF("submithonker", r) err := readviews.Execute(w, "honkers.html", templinfo) if err != nil {

@@ -2082,8 +2081,8 @@ }

func showchatter(w http.ResponseWriter, r *http.Request) { u := login.GetUserInfo(r) - chatnewnone(u.UserID) - chatter := loadchatter(u.UserID) + chatnewnone(UserID(u.UserID)) + chatter := loadchatter(UserID(u.UserID)) for _, chat := range chatter { for _, ch := range chat.Chonks { filterchonk(ch)

@@ -2109,14 +2108,14 @@ dt := time.Now().UTC()

xid := fmt.Sprintf("%s/%s/%s", user.URL, "chonk", xfiltrate()) if !strings.HasPrefix(target, "https://") { - target = fullname(target, u.UserID) + target = fullname(target, user.ID) } if target == "" { http.Error(w, "who is that?", http.StatusInternalServerError) return } ch := Chonk{ - UserID: u.UserID, + UserID: user.ID, XID: xid, Who: user.URL, Target: target,

@@ -2142,7 +2141,7 @@

http.Redirect(w, r, "/chatter", http.StatusSeeOther) } -var combocache = gencache.New(gencache.Options[int64, []string]{Fill: func(userid int64) ([]string, bool) { +var combocache = gencache.New(gencache.Options[UserID, []string]{Fill: func(userid UserID) ([]string, bool) { honkers := gethonkers(userid) var combos []string for _, h := range honkers {

@@ -2194,7 +2193,7 @@ var meta HonkerMeta

meta.Notes = strings.TrimSpace(r.FormValue("notes")) mj, _ := jsonify(&meta) - defer honkerinvalidator.Clear(u.UserID) + defer honkerinvalidator.Clear(user.ID) // mostly dummy, fill in later... h := &Honker{

@@ -2213,7 +2212,7 @@ }

if r.FormValue("sub") == "sub" { followyou(user, honkerid, false) } - _, err := stmtUpdateHonker.Exec(name, combos, mj, honkerid, u.UserID) + _, err := stmtUpdateHonker.Exec(name, combos, mj, honkerid, user.ID) if err != nil { elog.Printf("update honker err: %s", err) return nil

@@ -2245,9 +2244,9 @@ return h

} func hfcspage(w http.ResponseWriter, r *http.Request) { - userinfo := login.GetUserInfo(r) + u := login.GetUserInfo(r) - filters := getfilters(userinfo.UserID, filtAny) + filters := getfilters(UserID(u.UserID), filtAny) templinfo := getInfo(r) templinfo["Filters"] = filters

@@ -2486,7 +2485,7 @@ }

func webhydra(w http.ResponseWriter, r *http.Request) { u := login.GetUserInfo(r) - userid := u.UserID + userid := UserID(u.UserID) templinfo := getInfo(r) templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) page := r.FormValue("page")

@@ -2592,7 +2591,7 @@ }

func apihandler(w http.ResponseWriter, r *http.Request) { u := login.GetUserInfo(r) - userid := u.UserID + userid := UserID(u.UserID) action := r.FormValue("action") wait, _ := strconv.ParseInt(r.FormValue("wait"), 10, 0) dlog.Printf("api request '%s' on behalf of %s", action, u.Username)

@@ -2655,7 +2654,7 @@ xid := r.FormValue("xid")

honks = gethonksbyxonker(userid, xid, wanted) case "search": q := r.FormValue("q") - honks = gethonksbysearch(u.UserID, q, wanted) + honks = gethonksbysearch(userid, q, wanted) default: http.Error(w, "unknown page", http.StatusNotFound) return

@@ -2687,7 +2686,7 @@ go deliverate(userid, rcpt, msg)

} case "gethonkers": j := junk.New() - j["honkers"] = gethonkers(u.UserID) + j["honkers"] = gethonkers(userid) j.Write(w) case "savehonker": h := submithonker(w, r)