diff --git a/js/modules/loki_snode_api.js b/js/modules/loki_snode_api.js index d4b2a6cdc..9828ce43a 100644 --- a/js/modules/loki_snode_api.js +++ b/js/modules/loki_snode_api.js @@ -332,7 +332,7 @@ class LokiSnodeAPI { try { const conversation = ConversationController.get(pubKey); if (!conversation) { - throw new Error('Could not find conversation ', pubKey); + throw new Error(`Could not find conversation '${pubKey}'`); } const swarmNodes = [...conversation.get('swarmNodes')]; diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index 653075b37..06116b058 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -632,9 +632,11 @@ export async function handleMessageEvent(event: any): Promise { conversationId = primarySource.key; } - // the conversation with the primary device of that source (can be the same as conversationOrigin) - const conversation = window.ConversationController.get(conversationId); - + // be sure to call this one with conversationId. because we might need to create the primary conversation from a message of a secondary device + const conversation = await window.ConversationController.getOrCreateAndWait( + conversationId, + type + ); conversation.queueJob(() => { handleMessageJob( msg, diff --git a/ts/session/protocols/SessionProtocol.ts b/ts/session/protocols/SessionProtocol.ts index 45b3673f6..853bcbf1c 100644 --- a/ts/session/protocols/SessionProtocol.ts +++ b/ts/session/protocols/SessionProtocol.ts @@ -105,6 +105,10 @@ export class SessionProtocol { public static async sendSessionRequestIfNeeded( pubkey: PubKey ): Promise { + const { ConversationController } = window; + // FIXME audric: to remove once swarm nodes are not stored on the conversation itself. + await ConversationController.getOrCreateAndWait(pubkey.key, 'private'); + if ( (await SessionProtocol.hasSession(pubkey)) || (await SessionProtocol.hasSentSessionRequest(pubkey))