# HG changeset patch # User Ted Unangst # Date 1728503009 14400 # Wed Oct 09 15:43:29 2024 -0400 # Node ID d652b081516c41e6086c029a3704bf60207005e0 # Parent e78db3c308d5a000a0ad98700f2ccd3bbbf1d32d need to preserve more info when dehonking diff --git a/cli.go b/cli.go --- a/cli.go +++ b/cli.go @@ -152,7 +152,7 @@ errx("user not found") } - honkerid, err := gethonker(user.ID, args[2]) + honkerid, err := findhonkerid(user.ID, args[2]) if err != nil { errx("sorry couldn't find them") } diff --git a/database.go b/database.go --- a/database.go +++ b/database.go @@ -103,7 +103,7 @@ return user } -func gethonker(userid UserID, xid string) (int64, error) { +func findhonkerid(userid UserID, xid string) (int64, error) { row := opendatabase(). QueryRow("select honkerid from honkers where xid = ? and userid = ? and flavor in ('sub')", xid, userid) var honkerid int64 diff --git a/fun.go b/fun.go --- a/fun.go +++ b/fun.go @@ -595,22 +595,23 @@ return "" } -var evenshorternames = gencache.New(gencache.Options[UserID, map[string]int64]{Fill: func(userid UserID) (map[string]int64, bool) { +var honkerdirectory = gencache.New(gencache.Options[UserID, map[string]*Honker]{Fill: func(userid UserID) (map[string]*Honker, bool) { honkers := gethonkers(userid) - m := make(map[string]int64) + m := make(map[string]*Honker) for _, h := range honkers { - m[h.XID] = h.ID + m[h.XID] = h } return m, true }, Invalidator: &honkerinvalidator}) -func evenshortername(userid UserID, xid string) int64 { - m, ok := evenshorternames.Get(userid) +func gethonker(userid UserID, xid string) *Honker { + m, ok := honkerdirectory.Get(userid) if ok { return m[xid] } - return 0 + return nil } + 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) diff --git a/web.go b/web.go --- a/web.go +++ b/web.go @@ -948,7 +948,7 @@ func honkerhat(userid UserID, xid string, r *http.Request) template.HTML { var miniform template.HTML - sname := shortname(userid, xid); + sname := shortname(userid, xid) if sname == "" { sname = xid miniform = templates.Sprintf(`
@@ -957,12 +957,14 @@
`, login.GetCSRF("submithonker", r), xid) } else { - honkerid := evenshortername(userid, xid) + honker := gethonker(userid, xid) miniform = templates.Sprintf(`
+ + -
`, login.GetCSRF("submithonker", r), honkerid) + `, login.GetCSRF("submithonker", r), honker.ID, honker.Name, honker.Meta.Notes) } msg := templates.Sprintf(`honks by honker: %s%s`, xid, sname, miniform) return msg