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:
parent
76c165a10a
commit
04f0142b23
3 changed files with 4 additions and 24 deletions
|
@ -36987,19 +36987,9 @@ Internal.SessionLock.queueJobForNumber = function queueJobForNumber(number, runJ
|
||||||
if (numbers.filter(textsecure.utils.isNumberSane).length < numbers.length)
|
if (numbers.filter(textsecure.utils.isNumberSane).length < numbers.length)
|
||||||
throw new Error("Invalid number in new group members");
|
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; });
|
var added = numbers.filter(function(number) { return group.numbers.indexOf(number) < 0; });
|
||||||
|
|
||||||
return textsecure.storage.groups.addNumbers(groupId, added).then(function(newGroup) {
|
return textsecure.storage.groups.addNumbers(groupId, added);
|
||||||
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;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -345,10 +345,10 @@
|
||||||
groupId : dataMessage.group.id,
|
groupId : dataMessage.group.id,
|
||||||
name : dataMessage.group.name,
|
name : dataMessage.group.name,
|
||||||
avatar : dataMessage.group.avatar,
|
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')) || {};
|
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) {
|
if (difference.length > 0) {
|
||||||
group_update.joined = difference;
|
group_update.joined = difference;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,19 +139,9 @@
|
||||||
if (numbers.filter(textsecure.utils.isNumberSane).length < numbers.length)
|
if (numbers.filter(textsecure.utils.isNumberSane).length < numbers.length)
|
||||||
throw new Error("Invalid number in new group members");
|
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; });
|
var added = numbers.filter(function(number) { return group.numbers.indexOf(number) < 0; });
|
||||||
|
|
||||||
return textsecure.storage.groups.addNumbers(groupId, added).then(function(newGroup) {
|
return textsecure.storage.groups.addNumbers(groupId, added);
|
||||||
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;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue