From b3f22c698739bdd57dab77af45a0b8a43da72ca4 Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Sun, 1 Jan 2023 16:48:37 -0500 Subject: working ids and activity lookups --- models/outbox_item.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'models/outbox_item.go') 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) } -- cgit v1.2.3