feat: process DM WS events from all origins

Remove home-only restriction on DM events. Add federatedId
dedup check to dm_channel_created to prevent duplicate sidebar
entries for cross-instance DMs.
This commit is contained in:
Jannis Braun
2026-04-07 19:55:08 +02:00
parent b7c4a020db
commit 95f97c1526
+10 -3
View File
@@ -544,7 +544,7 @@ function handleEvent(origin: string, event: ServerEvent): void {
break; break;
} }
// ─── DM events (home-only) ────────────────────────────────────────────── // ─── DM events (all origins) ────────────────────────────────────────────
case 'dm_message_created': { case 'dm_message_created': {
if (!isHome) { if (!isHome) {
@@ -817,16 +817,23 @@ function handleEvent(origin: string, event: ServerEvent): void {
break; break;
} }
// ─── DM channel events (home-only) ────────────────────────────────────── // ─── DM channel events (all origins) ────────────────────────────────────
case 'dm_channel_created': case 'dm_channel_created': {
if (!isHome) { if (!isHome) {
for (const m of event.dmChannel.members) { for (const m of event.dmChannel.members) {
normalizeUserAssets(m, origin); normalizeUserAssets(m, origin);
} }
} }
// Dedup: skip if a channel with the same federatedId already exists
const fid = event.dmChannel.federatedId;
if (fid) {
const existing = useSpaceStore.getState().dmChannels.find(dm => dm.federatedId === fid);
if (existing) break;
}
addDmChannel(event.dmChannel, origin); addDmChannel(event.dmChannel, origin);
break; break;
}
case 'dm_channel_closed': case 'dm_channel_closed':
removeDmChannel(event.dmChannelId); removeDmChannel(event.dmChannelId);