all repos — honk @ b4634c4b64a43da9896cdafc1ad076e65f638ba6

my fork of honk

start saving boxes in the db
Ted Unangst tedu@tedunangst.com
Sat, 20 Apr 2019 11:38:16 -0400
commit

b4634c4b64a43da9896cdafc1ad076e65f638ba6

parent

5e1af23beb3ea7d5f84cf652f8b2f183d185b5fd

1 files changed, 17 insertions(+), 6 deletions(-)

jump to
M activity.goactivity.go

@@ -302,14 +302,25 @@ if ok {

return b, nil } - j, err := GetJunk(ident) + db := opendatabase() + + row := db.QueryRow("select ibox, obox, sbox from xonkers where xid = ?", ident) + b = &Box{} + err := row.Scan(&b.In, &b.Out, &b.Shared) if err != nil { - return nil, err + j, err := GetJunk(ident) + if err != nil { + return nil, err + } + inbox, _ := jsongetstring(j, "inbox") + outbox, _ := jsongetstring(j, "outbox") + sbox, _ := jsonfindstring(j, []string{"endpoints", "sharedInbox"}) + b = &Box{In: inbox, Out: outbox, Shared: sbox} + if inbox != "" { + db.Exec("insert into xonkers (xid, ibox, obox, sbox, pubkey) values (?, ?, ?, ?, ?)", + ident, inbox, outbox, sbox, "") + } } - inbox, _ := jsongetstring(j, "inbox") - outbox, _ := jsongetstring(j, "outbox") - sbox, _ := jsonfindstring(j, []string{"endpoints", "sharedInbox"}) - b = &Box{In: inbox, Out: outbox, Shared: sbox} boxlock.Lock() boxofboxes[ident] = b boxlock.Unlock()