aboutsummaryrefslogtreecommitdiff
path: root/models/outbox_item.go
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2023-01-01 21:48:37 +0000
committerJulio Capote <jcapote@gmail.com>2023-01-01 21:48:37 +0000
commitb3f22c698739bdd57dab77af45a0b8a43da72ca4 (patch)
tree07d4bca01bc49d71d2ddceaa89f51487f0768047 /models/outbox_item.go
parent71495ac61587e3380f413b4d34669a68b5cd8068 (diff)
downloadcommunique-b3f22c698739bdd57dab77af45a0b8a43da72ca4.tar.gz
working ids and activity lookups
Diffstat (limited to '')
-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)
}