Merge pull request #2251 from axxml/main

Add namespacedPlatformId exclusion for DeltaChat
This commit is contained in:
gavrielc
2026-05-04 18:32:18 +03:00
committed by GitHub

View File

@@ -9,15 +9,17 @@
* will later emit as event.platformId, or router lookups miss and messages * will later emit as event.platformId, or router lookups miss and messages
* get silently dropped. * get silently dropped.
* *
* Native adapters (Signal, WhatsApp, iMessage) use their own ID formats and * Native adapters (Signal, WhatsApp, iMessage, DeltaChat) use their own ID
* send them as-is — no channel prefix. WhatsApp/iMessage emit JIDs/emails * formats and send them as-is — no channel prefix. WhatsApp/iMessage emit
* containing '@'. Signal emits raw phone numbers ('+15551234567') for DMs * JIDs/emails containing '@'. Signal emits raw phone numbers ('+15551234567')
* and 'group:<id>' for group chats. Prefixing any of these would cause a * for DMs and 'group:<id>' for group chats. DeltaChat emits numeric chat IDs
* mismatch with what the adapter later emits. * ('12'). Prefixing any of these would cause a mismatch with what the adapter
* later emits.
*/ */
export function namespacedPlatformId(channel: string, raw: string): string { export function namespacedPlatformId(channel: string, raw: string): string {
if (raw.startsWith(`${channel}:`)) return raw; if (raw.startsWith(`${channel}:`)) return raw;
if (raw.includes('@')) return raw; if (raw.includes('@')) return raw;
if (raw.startsWith('+') || raw.startsWith('group:')) return raw; if (raw.startsWith('+') || raw.startsWith('group:')) return raw;
if (channel === 'deltachat') return raw;
return `${channel}:${raw}`; return `${channel}:${raw}`;
} }