feat(relay): return full envelope metadata and payload_hex in GET /v1/relay/mailboxes/:id

Open
#10 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
redis, rust
Domain
api, backend

Research direction

Start in src/http_server.rs around lines 165-235, where the GET mailbox route calls handle_get_mailbox, then read src/relay.rs and the WAL and Redis recovery code in src/storage.rs and src/redis_store.rs to see where payload_hex is kept per envelope. Return an items array with payload_hex next to the existing envelopes array. Done when tests/milestone10_node_test.rs round-trips the exact submitted payload_hex and the 13 existing tests still pass. The ack endpoint and WAL compaction are separate design work.

Written by the indexing model from the issue text.

Description

area::node effort::m impact::critical priority::critical source::auto status::review type::feature

Description

Currently, sonaraim-node stores payload_hex in WAL and Redis (src/storage.rs, src/redis_store.rs), but GET /v1/relay/mailboxes/:id (src/http_server.rs:170-185) only returns envelope ID strings ({"envelopes":["env_b2b_1_..."]}) without payload_hex or sender_did. As a result, sonaraim-app cannot decode and render the actual card or P2P message content queued in the mailbox.

Affected Files

  • src/http_server.rs:165-235
  • src/relay.rs:1-127
  • src/storage.rs:160-254

Evidence (Current Code Snippet)

// src/http_server.rs:172-177
        ("GET", p) if p.starts_with("/v1/relay/mailboxes/") => {
            let mbox = p.trim_start_matches("/v1/relay/mailboxes/");
            handle_get_mailbox(&st, mbox)
        }

Impact & Historical Context

  • Impact: Without returning payload_hex (and envelope_id, recipient_mailbox_id) in envelope_objects on GET /v1/relay/mailboxes/:id, downstream clients (sonaraim-app) only see opaque IDs and cannot render real cards or messages.
  • Historical Context: Parent Meta-Issue alfonsodg/sonaraim#15. Extends alfonsodg/sonaraim-node#3 and #6.

Proposed Solution

  1. Store (envelope_id, payload_hex) in NodeState / RelayQueue when handling POST /v1/relay/envelopes and during WAL/Redis recovery.
  2. In GET /v1/relay/mailboxes/:id, return both "envelopes": [...] (for backward compatibility) and "items": [{"envelope_id": "...", "recipient_mailbox_id": "...", "payload_hex": "..."}].
  3. Add POST /v1/relay/mailboxes/:id/ack to acknowledge/pop delivered envelopes and trigger WAL compaction.

Acceptance Criteria

  • Functional: GET /v1/relay/mailboxes/:id returns "items" containing the exact payload_hex submitted to POST /v1/relay/envelopes.
  • Code Quality: All files in src/ strictly < 300 lines; cargo fmt --check and cargo clippy -- -D warnings pass.
  • Tests: TDD tests in tests/milestone10_node_test.rs verify payload_hex round-trip through POST /v1/relay/envelopes -> GET /v1/relay/mailboxes/:id.
  • Regression: Existing "envelopes" array contract remains intact so all 13 existing tests pass.
Dominant language
Rust
Stars
0
Forks
0
Avg merge
4m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from alfonsodg/sonaraim-node

All issues in alfonsodg/sonaraim-node

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.