aboutsummaryrefslogtreecommitdiff
path: root/models/outbox_item.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/outbox_item.go')
-rw-r--r--models/outbox_item.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/models/outbox_item.go b/models/outbox_item.go
index 9950d9c..9d9de97 100644
--- a/models/outbox_item.go
+++ b/models/outbox_item.go
@@ -18,7 +18,7 @@ type OutboxItem struct {
CreatedAt time.Time
}
-// used for lookup purposes (count, collect)
+// used for lookup purposes (count, collect, find)
func NewOutboxItem(h config.Handler) *OutboxItem {
aso := &OutboxItem{Handler: h}
return aso
@@ -31,14 +31,13 @@ func CreateOutboxItem(h config.Handler, content []byte) *OutboxItem {
Handler: h,
CreatedAt: t,
Content: content,
- Id: k.Bytes(),
+ Id: []byte(k.String()), // NOTE: we want the bytes of the string representation of a hash, NOT a binary hash
}
return aso
}
-func (a *OutboxItem) keyName() []byte {
- key := fmt.Sprintf("%s:%s", a.Keybase(), a.Id)
- return []byte(key)
+func (a *OutboxItem) Key() string {
+ return fmt.Sprintf("%s:%s", a.Keybase(), a.Id)
}
func (a *OutboxItem) Keybase() string {
@@ -59,6 +58,6 @@ func (a *OutboxItem) Save(txn *badger.Txn) error {
if err != nil {
return fmt.Errorf("could not encode outbox item: %w", err)
}
- e := badger.NewEntry(a.keyName(), network.Bytes())
+ e := badger.NewEntry([]byte(a.Key()), network.Bytes())
return txn.SetEntry(e)
}