Ignore missing members in incoming group updates

Previously, updateNumbers would throw an Error, so the whole group
update was discarded.

Signal-Android handles this the same way in
GroupMessageProcessor.handleGroupUpdate().

Closes #1056
This commit is contained in:
haffenloher 2017-02-07 04:20:36 +01:00 committed by lilia
parent 76c165a10a
commit 04f0142b23
3 changed files with 4 additions and 24 deletions

View file

@ -36987,19 +36987,9 @@ Internal.SessionLock.queueJobForNumber = function queueJobForNumber(number, runJ
if (numbers.filter(textsecure.utils.isNumberSane).length < numbers.length)
throw new Error("Invalid number in new group members");
if (group.numbers.filter(function(number) { return numbers.indexOf(number) < 0 }).length > 0)
throw new Error("Attempted to remove numbers from group with an UPDATE");
var added = numbers.filter(function(number) { return group.numbers.indexOf(number) < 0; });
return textsecure.storage.groups.addNumbers(groupId, added).then(function(newGroup) {
if (numbers.filter(function(number) { return newGroup.indexOf(number) < 0; }).length != 0 ||
newGroup.filter(function(number) { return numbers.indexOf(number) < 0; }).length != 0) {
throw new Error("Error calculating group member difference");
}
return added;
});
return textsecure.storage.groups.addNumbers(groupId, added);
});
},

View file

@ -345,10 +345,10 @@
groupId : dataMessage.group.id,
name : dataMessage.group.name,
avatar : dataMessage.group.avatar,
members : dataMessage.group.members,
members : _.union(dataMessage.group.members, conversation.get('members')),
};
group_update = conversation.changedAttributes(_.pick(dataMessage.group, 'name', 'avatar')) || {};
var difference = _.difference(dataMessage.group.members, conversation.get('members'));
var difference = _.difference(attributes.members, conversation.get('members'));
if (difference.length > 0) {
group_update.joined = difference;
}

View file

@ -139,19 +139,9 @@
if (numbers.filter(textsecure.utils.isNumberSane).length < numbers.length)
throw new Error("Invalid number in new group members");
if (group.numbers.filter(function(number) { return numbers.indexOf(number) < 0 }).length > 0)
throw new Error("Attempted to remove numbers from group with an UPDATE");
var added = numbers.filter(function(number) { return group.numbers.indexOf(number) < 0; });
return textsecure.storage.groups.addNumbers(groupId, added).then(function(newGroup) {
if (numbers.filter(function(number) { return newGroup.indexOf(number) < 0; }).length != 0 ||
newGroup.filter(function(number) { return numbers.indexOf(number) < 0; }).length != 0) {
throw new Error("Error calculating group member difference");
}
return added;
});
return textsecure.storage.groups.addNumbers(groupId, added);
});
},