From d8df91fa154a49e4c510e390a006b0254c4e1b3d Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 9 Jul 2020 08:58:32 +1000 Subject: [PATCH] use the groupId as conversation id to create a conversation when this is a group --- ts/receiver/dataMessage.ts | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) 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 { 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 { // ========================================= - // 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,