Fix quote posts not loading: include relay hints in nevent URIs and q tags

This commit is contained in:
Alex Gleason
2026-03-15 04:19:02 -05:00
parent 1fbdd2f729
commit f92f50d5e0
2 changed files with 27 additions and 1 deletions
+1 -1
View File
@@ -737,7 +737,7 @@ export function ComposeBox({
if (showQuotedEvent && quotedEvent) {
tags.push(['q', quotedEvent.id, DITTO_RELAY, quotedEvent.pubkey]);
// Add the nostr: URI to the content if not already present
const neventUri = `nostr:${nip19.neventEncode({ id: quotedEvent.id, author: quotedEvent.pubkey })}`;
const neventUri = `nostr:${nip19.neventEncode({ id: quotedEvent.id, author: quotedEvent.pubkey, relays: [DITTO_RELAY] })}`;
if (!finalContent.includes(neventUri)) {
finalContent = finalContent + '\n\n' + neventUri;
}
+26
View File
@@ -378,6 +378,32 @@ export function NoteContent({
result.push({ type: 'text', value: text });
}
// Enrich nevent-embed tokens with relay hints from `q` tags when the
// nevent URI itself didn't include any. This ensures quote posts whose
// inline nevent was encoded without relay hints can still resolve the
// quoted event via the relay hint stored in the q tag.
const qTagMap = new Map<string, { relay?: string; author?: string }>();
for (const tag of event.tags) {
if (tag[0] === 'q' && tag[1]) {
qTagMap.set(tag[1], { relay: tag[2] || undefined, author: tag[3] || undefined });
}
}
if (qTagMap.size > 0) {
for (const token of result) {
if (token.type === 'nevent-embed') {
const qInfo = qTagMap.get(token.eventId);
if (qInfo) {
if ((!token.relays || token.relays.length === 0) && qInfo.relay) {
token.relays = [qInfo.relay];
}
if (!token.author && qInfo.author) {
token.author = qInfo.author;
}
}
}
}
}
// Collapse excessive whitespace around block-level tokens (link-preview, youtube-embed)
// Preserve formatting but prevent too much stacking with the card's own spacing.
for (let i = 0; i < result.length; i++) {