start saving boxes in the db
Ted Unangst tedu@tedunangst.com
Sat, 20 Apr 2019 11:38:16 -0400
1 files changed,
17 insertions(+),
6 deletions(-)
jump to
M
activity.go
→
activity.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()