Skip to content

fix(relay): wire custom filter fields through HTTP bridge#864

Merged
wpfleger96 merged 2 commits into
mainfrom
worktree-wpfleger-relay-bridge-custom-filters
Jun 5, 2026
Merged

fix(relay): wire custom filter fields through HTTP bridge#864
wpfleger96 merged 2 commits into
mainfrom
worktree-wpfleger-relay-bridge-custom-filters

Conversation

@wpfleger96

@wpfleger96 wpfleger96 commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • POST /query deserializes into nostr::Filter (external crate) which silently drops non-NIP-01 fields. The CLI (#850) injects before_id, depth_limit, and feed_types into filter JSON — all three vanish at the bridge layer while the DB already supports them.
  • Two-pass parse: deserialize as Vec<Value> first to extract custom fields, then convert to Vec<nostr::Filter> for standard processing.
  • Three routing paths based on which extension field is present:
    • before_id → populates EventQuery.before_id for composite keyset pagination; returns 400 if until is not also set
    • depth_limit → dispatches to get_thread_replies (thread_metadata table) instead of query_events, then batch-fetches full events by ID
    • feed_types → dispatches to dedicated feed query functions (query_feed_mentions, query_feed_needs_action, query_feed_activity); normalizes agent_activity to activity; enforces aggregate limit across types
  • HashSet<usize> tracks which filter indices were handled by intercepts so the standard loop skips them
  • event_in_accessible_channel helper extracts the repeated channel access post-filter pattern
  • Named constants BRIDGE_FEED_MAX_LIMIT / BRIDGE_THREAD_MAX_LIMIT replace inline magic numbers
  • 21 unit tests cover all extractor functions and the channel access helper

Related: #850 (CLI flags that send these fields)

@wpfleger96 wpfleger96 requested a review from a team as a code owner June 4, 2026 22:47
POST /query deserializes into nostr::Filter which silently drops
non-NIP-01 fields. The CLI (PR #850) injects before_id, depth_limit,
and feed_types — all three vanish at the bridge layer while the DB
already supports them.

Two-pass parse extracts custom fields from raw JSON before standard
deserialization. Routing: before_id populates EventQuery for keyset
pagination, depth_limit dispatches to get_thread_replies, feed_types
dispatches to the dedicated feed query functions.
Return 400 when before_id is sent without until instead of silently
dropping it. Add handled-index guard to depth_limit loop to prevent
double-processing. Extract event_in_accessible_channel helper to
replace three inline copies. Normalize agent_activity to activity to
avoid duplicate DB queries, enforce aggregate feed limit across types,
replace magic numbers with named constants, and add unit tests for all
extractor functions.
@wpfleger96 wpfleger96 force-pushed the worktree-wpfleger-relay-bridge-custom-filters branch from 70f042e to 400df8b Compare June 5, 2026 16:33
@wpfleger96 wpfleger96 merged commit 0311522 into main Jun 5, 2026
16 checks passed
@wpfleger96 wpfleger96 deleted the worktree-wpfleger-relay-bridge-custom-filters branch June 5, 2026 16:36
michaelneale added a commit that referenced this pull request Jun 6, 2026
* origin/main:
  chore(release): release version 0.3.12 (#886)
  Show hover cards for inline message emoji (#885)
  Fix monotonic read-state merges (#884)
  Refine sidebar behavior and borders (#869)
  fix(presence): clear on disconnect, fix heartbeat/TTL, drop broken REST path (#877)
  fix(cli): publish ephemeral events over WebSocket via sprout-ws-client (#876)
  docs(sprout-acp): add communication discipline rules to base prompt + deprecate --mention flag (#883)
  Polish thread summaries and reactions (#881)
  feat(cli): add emoji export and import subcommands (#882)
  Polish message row hover states (#880)
  Improve emoji naming and custom emoji UX (#878)
  docs: add ecosystem section to CONTRIBUTING.md, fix stale release info (#873)
  fix(relay): wire custom filter fields through HTTP bridge (#864)
  chore: deprecate sprout-mcp — fill CLI gaps, remove crate and all references (#850)
  Fix custom emoji status in profile popover (#874)
  fix(agent): gate handoff on provider token usage, not byte estimate (#821)
  docs: add VISION_MESH.md — the compute-commons vision (#867)
  fix(desktop): simplify profile popover header (#853)
  fix(desktop): remove thread comment hover outline (#861)
  feat(desktop): always show channel section search/add buttons (#856)

# Conflicts:
#	crates/sprout-cli/src/client.rs
#	desktop/src/app/AppShell.tsx
#	justfile
tellaho pushed a commit that referenced this pull request Jun 8, 2026
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
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.

1 participant