add nipb0/blossom helpers.

This commit is contained in:
fiatjaf
2025-03-04 12:42:24 -03:00
parent 5bfaed2740
commit 5bafd1c778
8 changed files with 366 additions and 0 deletions

24
nipb0/blossom/delete.go Normal file
View File

@@ -0,0 +1,24 @@
package blossom
import (
"context"
"fmt"
"github.com/nbd-wtf/go-nostr"
)
// Delete deletes a file from the media server by its hash
func (c *Client) Delete(ctx context.Context, hash string) error {
err := c.httpCall(ctx, "DELETE", c.mediaserver+"/"+hash, "", func() string {
return c.authorizationHeader(ctx, func(evt *nostr.Event) {
evt.Tags = append(evt.Tags, nostr.Tag{"t", "delete"})
evt.Tags = append(evt.Tags, nostr.Tag{"x", hash})
})
}, nil, 0, nil)
if err != nil {
return fmt.Errorf("failed to delete %s: %w", hash, err)
}
return nil
}