fix(federation): add participants array to relay events and fix recipient resolution

The relay was failing because processCreateEvent relied on the friends
table to discover the DM recipient, but friendships aren't federated
across instances. Also, resolveLocalUser matched deleted replicated
users before active ones.

- Add participants[] to FederationRelayEvent with homeUserId/homeInstance
  for all DM channel members
- Add getDmParticipants() helper to look up member identities
- Include participants in outbox payloads (create/update) and sync events
- Rewrite processCreateEvent to resolve participants directly, compute
  canonicalDmPairId, and findOrCreateDmChannel — removing the entire
  friends-list fallback (60+ lines)
- Fix resolveLocalUser to filter out deleted users (is_deleted = 0)
  and prefer the replicated user match when multiple candidates exist
This commit is contained in:
Jannis Braun
2026-03-26 05:36:41 +01:00
parent cb9a70d7a6
commit cf9fcb78ed
6 changed files with 94 additions and 126 deletions
+6
View File
@@ -717,12 +717,18 @@ export interface AdminResetPasswordResponse {
// ─── Federation Relay Types ──────────────────────────────────────────────────
export interface FederationRelayParticipant {
homeUserId: string;
homeInstance: string;
}
export interface FederationRelayEvent {
eventType: 'create' | 'update' | 'delete' | 'reaction_add' | 'reaction_remove';
dmChannelId: string;
messageId: string;
encryptionVersion: 0;
timestamp: number;
participants?: FederationRelayParticipant[];
message?: {
userId: string;
homeUserId: string;