khatru/blossom: get rid of custom BlobDescriptor with useless Owner field.

This commit is contained in:
fiatjaf
2026-01-13 00:03:49 -03:00
parent 14acd4b740
commit b9f1f93561
4 changed files with 24 additions and 34 deletions
+10 -7
View File
@@ -17,7 +17,11 @@ type EventStoreBlobIndexWrapper struct {
ServiceURL string
}
func (es EventStoreBlobIndexWrapper) Keep(ctx context.Context, blob BlobDescriptor, pubkey nostr.PubKey) error {
func (es EventStoreBlobIndexWrapper) Keep(
ctx context.Context,
blob blossom.BlobDescriptor,
pubkey nostr.PubKey,
) error {
next, stop := iter.Pull(
es.Store.QueryEvents(nostr.Filter{Authors: []nostr.PubKey{pubkey}, Kinds: []nostr.Kind{24242}, Tags: nostr.TagMap{"x": []string{blob.SHA256}}}, 1),
)
@@ -42,8 +46,8 @@ func (es EventStoreBlobIndexWrapper) Keep(ctx context.Context, blob BlobDescript
return nil
}
func (es EventStoreBlobIndexWrapper) List(ctx context.Context, pubkey nostr.PubKey) iter.Seq[BlobDescriptor] {
return func(yield func(BlobDescriptor) bool) {
func (es EventStoreBlobIndexWrapper) List(ctx context.Context, pubkey nostr.PubKey) iter.Seq[blossom.BlobDescriptor] {
return func(yield func(blossom.BlobDescriptor) bool) {
for evt := range es.Store.QueryEvents(nostr.Filter{
Authors: []nostr.PubKey{pubkey},
Kinds: []nostr.Kind{24242},
@@ -53,7 +57,7 @@ func (es EventStoreBlobIndexWrapper) List(ctx context.Context, pubkey nostr.PubK
}
}
func (es EventStoreBlobIndexWrapper) Get(ctx context.Context, sha256 string) (*BlobDescriptor, error) {
func (es EventStoreBlobIndexWrapper) Get(ctx context.Context, sha256 string) (*blossom.BlobDescriptor, error) {
next, stop := iter.Pull(
es.Store.QueryEvents(nostr.Filter{Tags: nostr.TagMap{"x": []string{sha256}}, Kinds: []nostr.Kind{24242}, Limit: 1}, 1),
)
@@ -87,14 +91,13 @@ func (es EventStoreBlobIndexWrapper) Delete(ctx context.Context, sha256 string,
return nil
}
func (es EventStoreBlobIndexWrapper) parseEvent(evt nostr.Event) BlobDescriptor {
func (es EventStoreBlobIndexWrapper) parseEvent(evt nostr.Event) blossom.BlobDescriptor {
hhash := evt.Tags[0][1]
mimetype := evt.Tags[1][1]
ext := blossom.GetExtension(mimetype)
size, _ := strconv.Atoi(evt.Tags[2][1])
return BlobDescriptor{
Owner: evt.PubKey,
return blossom.BlobDescriptor{
Uploaded: evt.CreatedAt,
URL: es.ServiceURL + "/" + hhash + ext,
SHA256: hhash,