From ebfff824bd220ab04206ae10c7787b1df1407207 Mon Sep 17 00:00:00 2001 From: Mikunj Varsani Date: Thu, 13 Feb 2020 13:44:53 +1100 Subject: [PATCH] Fix friend request logic triggerring on session requests --- libtextsecure/outgoing_message.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index 3749b2e1b..369f8ecee 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -391,6 +391,8 @@ OutgoingMessage.prototype = { : null; const isEndSession = flags === textsecure.protobuf.DataMessage.Flags.END_SESSION; + const isSessionRequest = + flags === textsecure.protobuf.DataMessage.Flags.SESSION_REQUEST; const signalCipher = new libsignal.SessionCipher( textsecure.storage.protocol, address @@ -485,6 +487,7 @@ OutgoingMessage.prototype = { content, pubKey: devicePubKey, isFriendRequest: enableFallBackEncryption, + isSessionRequest, }; }) ) @@ -494,7 +497,12 @@ OutgoingMessage.prototype = { if (!outgoingObject) { return; } - const destination = outgoingObject.pubKey; + const { + pubKey: destination, + ttl, + isFriendRequest, + isSessionRequest, + } = outgoingObject; try { const socketMessage = await this.wrapInWebsocketMessage( outgoingObject @@ -503,9 +511,9 @@ OutgoingMessage.prototype = { destination, socketMessage, this.timestamp, - outgoingObject.ttl + ttl ); - if (outgoingObject.isFriendRequest) { + if (!this.isGroup && isFriendRequest && !isSessionRequest) { const conversation = ConversationController.get(destination); if (conversation) { // Redundant for primary device but marks secondary devices as pending