Files
grimoire/src/types
Alejandro 8e4442ae34 feat: improve embedded event resolution with relay hints (#200)
* fix: parse NIP-29 q-tags with relay hints for embedded event resolution

The issue was that q-tag relay hints were being discarded when parsing
chat messages. When a message quoted another event, only the event ID
was extracted from the q-tag, ignoring the relay URL hint at tag[2].

Changes:
- Add getEventPointerFromQTag and getQuotePointer helpers to nostr-utils
- Update Message.replyTo type from string to EventPointer | AddressPointer
- Update all chat adapters (NIP-29, NIP-10, NIP-53, NIP-C7) to parse
  full pointers with relay hints
- Update loadReplyMessage signature to accept EventPointer with relays
- Update ReplyPreview to pass full pointers to event loading
- Update ChatView and ChatViewer to use new pointer-based q-tag parsing

This ensures embedded events (quotes/replies) are fetched using the
relay hint from the q-tag when the event is not found in the local store.

* fix: pass full EventPointer with relay hints through embed chain

The previous commit fixed q-tag parsing in chat adapters, but the
RichText/Mention chain was also discarding relay hints from nevent.

EventEmbed was only extracting `pointer.id` and passing it as a string
to QuotedEvent, losing the relay hints. Same issue in EmbeddedEvent.

Changes:
- Update QuotedEvent props: eventPointer instead of eventId string
- Update EmbeddedEvent props: eventPointer instead of eventId string
- Update EventEmbed to pass full pointer to QuotedEvent
- Update MarkdownContent to pass full pointers for note/nevent
- Update EventRefList to pass full pointer instead of just ID
- Update HighlightDetailRenderer to pass full eventPointer
- Update RepostRenderer to extract e-tag as EventPointer with hints

Now nevent mentions in content like nostr:nevent1... correctly use
the relay hints from the bech32 encoding when fetching the event.

* fix: use EventPointer for repost replyTo in NIP-10 adapter

Apply the same relay hints fix to the repostToMessage function that was
added in a recent main commit.

* refactor: use applesauce helpers for relay operations in chat adapters

- Use mergeRelaySets for relay deduplication and normalization
- Use getOutboxes helper instead of manual relay list parsing
- Simplify getThreadRelays in NIP-10 adapter
- Simplify loadReplyMessage in NIP-10, NIP-29, and NIP-53 adapters

* refactor: use mergeRelaySets in relay-selection service

- Simplify selectRelaysForInteraction using mergeRelaySets for priority-based relay combination
- Use mergeRelaySets for unique relay extraction in selectRelaysForFilter
- Reduces manual Set operations and gains automatic normalization

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-22 17:39:58 +01:00
..
2026-01-22 16:14:55 +01:00
2026-01-21 12:23:41 +01:00