Skip to content

Conversation

@claudespiral
Copy link

Summary

Populates replyMetadata when saving DM messages that contain repliesToMessageId, enabling the existing reply display UI to show "Replying to X".

Problem

For Quorum DMs, the relay hub only sees encrypted blobs (E2E encryption via X3DH + Double Ratchet). Unlike Farcaster where the server returns inReplyTo with full context, Quorum's API only returns the message ID reference inside encrypted content.

The mobile app has full support for displaying reply indicators (MessagesList.tsx checks replyToAuthor), but replyMetadata was never being populated for DMs.

Solution

In mmkvAdapter.saveMessage(), after loading existing messages, look up the parent message and populate replyMetadata:

if (content?.repliesToMessageId && !message.replyMetadata) {
  const parentMessage = messages.find((m) => m.messageId === content.repliesToMessageId);
  if (parentMessage?.content?.senderId) {
    message.replyMetadata = {
      parentAuthor: parentContent.senderId,
      parentChannelId: parentMessage.channelId,
    };
  }
}

Testing

  • Unit tests verify the logic handles: normal replies, non-replies, missing parents, existing metadata, malformed parents
  • Lint passes

Edge Cases

  • Parent message not loaded yet → replyMetadata stays undefined (graceful degradation)
  • Parent message deleted → same graceful handling
  • Existing replyMetadata → not overwritten

E2E encrypted messages only contain repliesToMessageId - the relay
hub cannot do server-side joins. This populates replyMetadata by
looking up the parent message locally when saving, enabling the
existing reply display UI to show 'Replying to X'.

Mirrors the pattern used by Farcaster DMs where inReplyTo context
comes from the API (server has access to message content).
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