Skip to content

feat: subscribe to protocol v2 (kind 14) events in the Nostr listener - #32

Merged
AndreaDiazCorreia merged 1 commit into
mainfrom
feat/protocol-v2-kind-14-listener
Jul 15, 2026
Merged

feat: subscribe to protocol v2 (kind 14) events in the Nostr listener#32
AndreaDiazCorreia merged 1 commit into
mainfrom
feat/protocol-v2-kind-14-listener

Conversation

@grunch

@grunch grunch commented Jul 14, 2026

Copy link
Copy Markdown
Member

Problem

Mobile users on v1.3.0 report missing notifications when their orders are taken (companion mobile PRs: MostroP2P/mobile#640, MostroP2P/mobile#641).

The mobile v1.3.0 release completed the transport v2 migration: against a daemon advertising protocol_version=2, node→client messages are signed kind-14 NIP-44 direct messages addressed to the trade pubkey in the p tag — not kind-1059 gift wraps.

The listener (src/nostr/listener.rs) only subscribed to kind 1059. Against a v2 node it never matches any event, so no FCM/UnifiedPush wake is ever dispatched and users get no notifications while the app is killed or dozing. Notifications only appear when they reopen the app.

Fix

  • Subscribe to kinds 1059 and 14 and dispatch on either, matching by p tag only.
  • No author filter is added — hard constraint feat: add POST /api/notify with dual-keyed rate limiting (v1.1) #1 stands. For kind 14 the author is the daemon, but the p-tag-only match is sufficient: pushes fire solely for registered trade pubkeys, and payloads are silent wake-ups.
  • Extract the p-tag lookup into extract_recipient() and add a watched_kinds() helper so the kind set has a single definition (filter + handler).
  • Update config.rs default event_kinds (doc-parity field), config.toml.example, and the kind-1059 mentions in README / docs / CLAUDE.md.

Test plan

  • New unit tests in src/nostr/listener.rs:
    • watched kinds include 1059 and 14
    • unrelated kinds (1, 10002, 38385) are not watched
    • extract_recipient returns the first p tag / None without one
  • cargo fmt — clean
  • cargo clippy --all-targets — no warnings
  • cargo test — 46 tests pass

Notes for reviewers

Mostro daemons advertising protocol_version=2 reply to clients with
signed kind-14 NIP-44 direct messages addressed to the trade pubkey in
the p tag, instead of kind-1059 gift wraps. The listener only watched
kind 1059, so against a v2 node it never matched any event: no FCM/
UnifiedPush wake was ever dispatched and mobile users stopped getting
notifications while the app was killed or dozing (reported after the
mobile v1.3.0 transport v2 rollout).

Subscribe to kinds 1059 and 14 and dispatch on either, still matching
by p tag only. No author filter is added (hard constraint #1 stands):
pushes fire solely for registered trade pubkeys, so the p-tag match is
sufficient for kind 14 as well.

Also extract the p-tag lookup into extract_recipient() and add unit
tests for the watched-kind set and recipient extraction.
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@grunch, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 16d9c825-fd26-40c0-9ce9-73d5d1f257b9

📥 Commits

Reviewing files that changed from the base of the PR and between e707cde and 59346e8.

📒 Files selected for processing (8)
  • CLAUDE.md
  • README.md
  • config.toml.example
  • docs/README.md
  • docs/architecture.md
  • docs/configuration.md
  • src/config.rs
  • src/nostr/listener.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/protocol-v2-kind-14-listener

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AndreaDiazCorreia
AndreaDiazCorreia merged commit 0ea135d into main Jul 15, 2026
4 checks passed
@grunch
grunch deleted the feat/protocol-v2-kind-14-listener branch July 15, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants