feat: Add GET /list/<pubkey> endpoint (BUD-12)#4
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds BUD-12 support for listing blobs owned by a pubkey via a new GET /list/<pubkey> HTTP endpoint, including optional auth validation and cursor/limit filtering, plus response serialization and tests.
Changes:
- Implement
GET /list/<pubkey>request handling with query params (since,until,limit,cursor) and optionalAuthorizationvalidation (t=list). - Add
Success_listresponse kind and JSON serialization for descriptor arrays. - Extend DB interface/implementation with
list_by_pubkeyand add unit + E2E test coverage for list behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_http_response.ml | Adds unit tests for Success_list HTTP response formatting (empty + populated arrays). |
| lib/shell/http_server.ml | Adds routing/handler logic for GET /list/<pubkey> including query parsing, cursor handling, and optional auth. |
| lib/shell/http_response.ml | Introduces Success_list response generation and refactors descriptor JSON conversion. |
| lib/shell/db_intf.ml | Extends DB interface with list_by_pubkey for BUD-12 listing. |
| lib/shell/blossom_db.ml | Implements list_by_pubkey SQL query and maps rows to Domain.blob_descriptor. |
| lib/core/auth.ml | Adds List action (t=list) support to auth validation. |
| e2e/test_list.ml | Adds E2E coverage for list sorting, filters, pagination, and auth behaviors. |
| e2e/nostr_signer.ml | Adds helper to sign t=list auth events for E2E tests. |
| e2e/main.ml | Wires list E2E tests into the runner output sequence. |
| e2e/dune | Registers the new test_list module in the E2E library. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Error "Invalid cursor" | ||
| else | ||
| (match BlobService.get_metadata ~storage:data_dir ~db ~sha256:sha with | ||
| | Ok meta -> Ok (Some (meta.uploaded, sha)) |
Comment on lines
+240
to
+247
| let cursor_uploaded, cursor_sha256 = match cursor with | ||
| | None -> 0L, "" | ||
| | Some (u, s) -> u, s | ||
| in | ||
| let result = | ||
| Caqti_eio.Pool.use (fun (module C : Caqti_eio.CONNECTION) -> | ||
| C.collect_list Db.list_blobs_by_pubkey | ||
| (pubkey, since, until, cursor_uploaded, cursor_sha256, limit) |
| ("sha256", `String descriptor.sha256); | ||
| ("size", `Int descriptor.size); | ||
| ("type", `String descriptor.mime_type); | ||
| ("uploaded", `Int (Int64.to_int descriptor.uploaded)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.