create convo for both primary and secondary in receivemessage

pull/1219/head
Audric Ackermann 5 years ago
parent 2257420523
commit 235ab0bfb3
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -332,7 +332,7 @@ class LokiSnodeAPI {
try { try {
const conversation = ConversationController.get(pubKey); const conversation = ConversationController.get(pubKey);
if (!conversation) { if (!conversation) {
throw new Error('Could not find conversation ', pubKey); throw new Error(`Could not find conversation '${pubKey}'`);
} }
const swarmNodes = [...conversation.get('swarmNodes')]; const swarmNodes = [...conversation.get('swarmNodes')];

@ -632,9 +632,11 @@ export async function handleMessageEvent(event: any): Promise<void> {
conversationId = primarySource.key; conversationId = primarySource.key;
} }
// the conversation with the primary device of that source (can be the same as conversationOrigin) // 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 = window.ConversationController.get(conversationId); const conversation = await window.ConversationController.getOrCreateAndWait(
conversationId,
type
);
conversation.queueJob(() => { conversation.queueJob(() => {
handleMessageJob( handleMessageJob(
msg, msg,

@ -105,6 +105,10 @@ export class SessionProtocol {
public static async sendSessionRequestIfNeeded( public static async sendSessionRequestIfNeeded(
pubkey: PubKey pubkey: PubKey
): Promise<void> { ): Promise<void> {
const { ConversationController } = window;
// FIXME audric: to remove once swarm nodes are not stored on the conversation itself.
await ConversationController.getOrCreateAndWait(pubkey.key, 'private');
if ( if (
(await SessionProtocol.hasSession(pubkey)) || (await SessionProtocol.hasSession(pubkey)) ||
(await SessionProtocol.hasSentSessionRequest(pubkey)) (await SessionProtocol.hasSentSessionRequest(pubkey))

Loading…
Cancel
Save