start saving boxes in the db
This commit is contained in:
parent
770e57797e
commit
30e1657d7a
11
activity.go
11
activity.go
|
@ -302,6 +302,12 @@ func getboxes(ident string) (*Box, error) {
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
j, err := GetJunk(ident)
|
j, err := GetJunk(ident)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -310,6 +316,11 @@ func getboxes(ident string) (*Box, error) {
|
||||||
outbox, _ := jsongetstring(j, "outbox")
|
outbox, _ := jsongetstring(j, "outbox")
|
||||||
sbox, _ := jsonfindstring(j, []string{"endpoints", "sharedInbox"})
|
sbox, _ := jsonfindstring(j, []string{"endpoints", "sharedInbox"})
|
||||||
b = &Box{In: inbox, Out: outbox, Shared: sbox}
|
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, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
boxlock.Lock()
|
boxlock.Lock()
|
||||||
boxofboxes[ident] = b
|
boxofboxes[ident] = b
|
||||||
boxlock.Unlock()
|
boxlock.Unlock()
|
||||||
|
|
Loading…
Reference in New Issue