From 3a1f07117781ad962c73999c5dca924b15126658 Mon Sep 17 00:00:00 2001 From: Maxim Shishmarev Date: Wed, 6 May 2020 10:42:30 +1000 Subject: [PATCH] Medium group messages show correct sender --- libtextsecure/message_receiver.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index de913df47..837cc3b48 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -682,7 +682,7 @@ MessageReceiver.prototype.extend({ const { senderIdentity } = envelope; const { - ciphertext: ciphertext2, + ciphertext: outerCiphertext, ephemeralKey, } = textsecure.protobuf.MediumGroupContent.decode(ciphertextObj); @@ -692,16 +692,16 @@ MessageReceiver.prototype.extend({ 'hex' ).toArrayBuffer(); - const res = await libloki.crypto.decryptForPubkey( + const mediumGroupCiphertext = await libloki.crypto.decryptForPubkey( secretKey, ephemKey, - ciphertext2.toArrayBuffer() + outerCiphertext.toArrayBuffer() ); const { ciphertext, keyIdx, - } = textsecure.protobuf.MediumGroupCiphertext.decode(res); + } = textsecure.protobuf.MediumGroupCiphertext.decode(mediumGroupCiphertext); const plaintext = await window.SenderKeyAPI.decryptWithSenderKey( ciphertext.toArrayBuffer(), @@ -1310,10 +1310,19 @@ MessageReceiver.prototype.extend({ // Build a 'message' event i.e. a received message event const ev = new Event('message'); + + const source = envelope.senderIdentity || senderPubKey; + + if (envelope.senderIdentity) { + message.group = { + id: envelope.source + }; + } + ev.confirm = this.removeFromCache.bind(this, envelope); ev.data = { friendRequest: isFriendRequest, - source: senderPubKey, + source, sourceDevice: envelope.sourceDevice, timestamp: envelope.timestamp.toNumber(), receivedAt: envelope.receivedAt,