all repos — honk @ d9e8d6cbe1753f22527f9914148ce7af1bd6601a

my fork of honk

also save handle when ingesting
Ted Unangst tedu@tedunangst.com
Mon, 11 Nov 2019 12:52:08 -0500
commit

d9e8d6cbe1753f22527f9914148ce7af1bd6601a

parent

75da70289f898fba3d3f9f1be38546277d78b9be

2 files changed, 27 insertions(+), 4 deletions(-)

jump to
M activity.goactivity.go

@@ -1389,6 +1389,7 @@ if ok {

ingestpubkey(origin, keyobj) } ingestboxes(origin, obj) + ingesthandle(origin, obj) } func ingestpubkey(origin string, obj junk.Junk) {

@@ -1439,6 +1440,9 @@ ident, _ := obj.GetString("id")

if ident == "" { return } + if originate(ident) != origin { + return + } var info string row := stmtGetXonker.QueryRow(ident, "boxes") err := row.Scan(&info)

@@ -1457,3 +1461,26 @@ log.Printf("error saving boxes: %s", err)

} } } + +func ingesthandle(origin string, obj junk.Junk) { + xid, _ := obj.GetString("id") + if xid == "" { + return + } + if originate(xid) != origin { + return + } + var handle string + row := stmtGetXonker.QueryRow(xid, "handle") + err := row.Scan(&handle) + if err == nil { + return + } + handle, _ = obj.GetString("preferredUsername") + if handle != "" { + _, err = stmtSaveXonker.Exec(xid, handle, "handle") + if err != nil { + log.Printf("error saving handle: %s", err) + } + } +}
M fun.gofun.go

@@ -508,10 +508,6 @@ handle = xid

} } else { handle = info.Name - _, err = stmtSaveXonker.Exec(xid, handle, "handle") - if err != nil { - log.Printf("error saving handle: %s", err) - } } } return handle, true