From 814b9cf26a69476c49cd25365b095c37d485aae1 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Mon, 17 Sep 2018 15:58:27 -0700 Subject: [PATCH] Only accept 'you left group' messages when group blocked --- js/background.js | 4 ++-- libtextsecure/message_receiver.js | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/js/background.js b/js/background.js index 7215afa66..4692e4bf6 100644 --- a/js/background.js +++ b/js/background.js @@ -920,9 +920,9 @@ updates.left = true; } - if (details.blocked === true) { + if (details.blocked) { storage.addBlockedGroup(id); - } else if (details.blocked === false) { + } else { storage.removeBlockedGroup(id); } diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index e0ea57c0b..b1ac69351 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -730,9 +730,12 @@ MessageReceiver.prototype.extend({ const groupId = message.group && message.group.id; const isBlocked = this.isGroupBlocked(groupId); const isMe = envelope.source === textsecure.storage.user.getNumber(); - const hasGroupMetadata = Boolean(message.group); + const isLeavingGroup = Boolean( + message.group && + message.group.type === textsecure.protobuf.GroupContext.Type.QUIT + ); - if (groupId && isBlocked && !(isMe && hasGroupMetadata)) { + if (groupId && isBlocked && !(isMe && isLeavingGroup)) { window.log.warn( `Message ${this.getEnvelopeId( envelope @@ -768,9 +771,12 @@ MessageReceiver.prototype.extend({ const groupId = message.group && message.group.id; const isBlocked = this.isGroupBlocked(groupId); const isMe = envelope.source === textsecure.storage.user.getNumber(); - const hasGroupMetadata = Boolean(message.group); + const isLeavingGroup = Boolean( + message.group && + message.group.type === textsecure.protobuf.GroupContext.Type.QUIT + ); - if (groupId && isBlocked && !(isMe && hasGroupMetadata)) { + if (groupId && isBlocked && !(isMe && isLeavingGroup)) { window.log.warn( `Message ${this.getEnvelopeId( envelope