diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index 293103cb8..575534f10 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -599,7 +599,24 @@ export async function handleMessageEvent(event: MessageEvent): Promise<void> { sendDeliveryReceipt(source, data.timestamp); } - await window.ConversationController.getOrCreateAndWait(id, type); + // Conversation Id is: + // - primarySource if it is an incoming DM message, + // - destination if it is an outgoing message, + // - group.id if it is a group message + let conversationId = id; + if (isGroupMessage) { + /* handle one part of the group logic here: + handle requesting info of a new group, + dropping an admin only update from a non admin, ... + */ + conversationId = message.group.id; + } + + if (!conversationId) { + window.console.warn('Invalid conversation id for incoming message', conversationId); + } + + await window.ConversationController.getOrCreateAndWait(conversationId, type); // =========== Process flags ============= @@ -613,20 +630,12 @@ export async function handleMessageEvent(event: MessageEvent): Promise<void> { // ========================================= - // Conversation Id is: - // - primarySource if it is an incoming DM message, - // - destination if it is an outgoing message, - // - group.id if it is a group message - let conversationId = id; - const primarySource = await MultiDeviceProtocol.getPrimaryDevice(source); if (isGroupMessage) { /* handle one part of the group logic here: handle requesting info of a new group, dropping an admin only update from a non admin, ... */ - conversationId = message.group.id; - const shouldReturn = await preprocessGroupMessage( source, message.group,