diff options
author | Julio Capote <jcapote@gmail.com> | 2022-12-19 04:58:09 +0000 |
---|---|---|
committer | Julio Capote <jcapote@gmail.com> | 2022-12-19 04:58:09 +0000 |
commit | baf3d4cd12ac1dda157507f648ae1fb4fa95b58c (patch) | |
tree | df050a68c42aa720c422702dad053fd7321ae0ec /resources | |
parent | 52dccf70722642ecf701bf5df900b779f168cc1b (diff) | |
download | communique-baf3d4cd12ac1dda157507f648ae1fb4fa95b58c.tar.gz |
err handling
Diffstat (limited to '')
-rw-r--r-- | resources/outbox.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/resources/outbox.go b/resources/outbox.go index 4ac4c6c..ed87dd8 100644 --- a/resources/outbox.go +++ b/resources/outbox.go @@ -32,7 +32,7 @@ func RenderOutboxPage(name, domain string, db *badger.DB) (map[string]interface{ itemsProp := streams.NewActivityStreamsOrderedItemsProperty() - db.View(func(txn *badger.Txn) error { + err = db.View(func(txn *badger.Txn) error { it := txn.NewIterator(badger.DefaultIteratorOptions) defer it.Close() prefix := []byte("outbox:sample") // TODO @@ -58,6 +58,9 @@ func RenderOutboxPage(name, domain string, db *badger.DB) (map[string]interface{ } return nil }) + if err != nil { + return nil, err + } oc.SetActivityStreamsOrderedItems(itemsProp) return streams.Serialize(oc) @@ -82,15 +85,18 @@ func RenderOutbox(name, domain string, db *badger.DB) (map[string]interface{}, e oc.SetJSONLDId(idProp) var i int - db.View(func(txn *badger.Txn) error { + err = db.View(func(txn *badger.Txn) error { it := txn.NewIterator(badger.DefaultIteratorOptions) defer it.Close() - prefix := []byte("outbox:sample") + prefix := []byte("outbox:sample") // TODO for it.Seek(prefix); it.ValidForPrefix(prefix); it.Next() { i++ } return nil }) + if err != nil { + return nil, err + } itemsProp := streams.NewActivityStreamsTotalItemsProperty() itemsProp.Set(i) |