From 2f469835d959326c4a30e10227e345121a89a779 Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 3 Dec 2015 18:48:04 -0800 Subject: [PATCH] Handle group quit sync messages Previously, we would incorrectly reject group updates originating from a linked device instructing us to remove ourselves from the group. // FREEBIE --- js/libtextsecure.js | 8 ++++++-- js/models/messages.js | 6 +++++- libtextsecure/message_receiver.js | 8 ++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index fdc526b2..19f3a687 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -37062,7 +37062,11 @@ MessageReceiver.prototype = { case textsecure.protobuf.GroupContext.Type.QUIT: decrypted.body = null; decrypted.attachments = []; - return textsecure.storage.groups.removeNumber(decrypted.group.id, source); + if (source === this.number) { + return textsecure.storage.groups.deleteGroup(decrypted.group.id); + } else { + return textsecure.storage.groups.removeNumber(decrypted.group.id, source); + } case textsecure.protobuf.GroupContext.Type.DELIVER: decrypted.group.name = null; decrypted.group.members = []; @@ -37073,7 +37077,7 @@ MessageReceiver.prototype = { throw new Error("Unknown group message type"); } } - })); + }.bind(this))); } for (var i in decrypted.attachments) { diff --git a/js/models/messages.js b/js/models/messages.js index 061ddfd3..1f85fd99 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -280,7 +280,11 @@ } } else if (dataMessage.group.type === textsecure.protobuf.GroupContext.Type.QUIT) { - group_update = { left: source }; + if (source == textsecure.storage.user.getNumber()) { + group_update = { left: "You" }; + } else { + group_update = { left: source }; + } attributes.members = _.without(conversation.get('members'), source); } diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index f2ca08f7..4b70fdc2 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -331,7 +331,11 @@ MessageReceiver.prototype = { case textsecure.protobuf.GroupContext.Type.QUIT: decrypted.body = null; decrypted.attachments = []; - return textsecure.storage.groups.removeNumber(decrypted.group.id, source); + if (source === this.number) { + return textsecure.storage.groups.deleteGroup(decrypted.group.id); + } else { + return textsecure.storage.groups.removeNumber(decrypted.group.id, source); + } case textsecure.protobuf.GroupContext.Type.DELIVER: decrypted.group.name = null; decrypted.group.members = []; @@ -342,7 +346,7 @@ MessageReceiver.prototype = { throw new Error("Unknown group message type"); } } - })); + }.bind(this))); } for (var i in decrypted.attachments) {