From 81408578798cabae8b0635f42faf0abfd06bb8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Thu, 6 Mar 2025 11:55:26 -0800 Subject: [PATCH] nipb0: Add authorization headers to Blossom downloads --- nipb0/blossom/download.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nipb0/blossom/download.go b/nipb0/blossom/download.go index 0cf09b3..f3ba5e5 100644 --- a/nipb0/blossom/download.go +++ b/nipb0/blossom/download.go @@ -21,6 +21,12 @@ func (c *Client) Download(ctx context.Context, hash string) ([]byte, error) { return nil, fmt.Errorf("failed to create request: %w", err) } + authHeader := c.authorizationHeader(ctx, func(evt *nostr.Event) { + evt.Tags = append(evt.Tags, nostr.Tag{"t", "get"}) + evt.Tags = append(evt.Tags, nostr.Tag{"x", hash}) + }) + req.Header.Add("Authorization", authHeader) + resp, err := http.DefaultClient.Do(req) if err != nil { return nil, fmt.Errorf("failed to call %s for %s: %w", c.mediaserver, hash, err) @@ -45,6 +51,12 @@ func (c *Client) DownloadToFile(ctx context.Context, hash string, filePath strin return fmt.Errorf("failed to create request: %w", err) } + authHeader := c.authorizationHeader(ctx, func(evt *nostr.Event) { + evt.Tags = append(evt.Tags, nostr.Tag{"t", "get"}) + evt.Tags = append(evt.Tags, nostr.Tag{"x", hash}) + }) + req.Header.Add("Authorization", authHeader) + resp, err := http.DefaultClient.Do(req) if err != nil { return fmt.Errorf("failed to call %s for %s: %w", c.mediaserver, hash, err)