|
|
|
@ -1018,7 +1018,9 @@ MessageReceiver.prototype.extend({
|
|
|
|
|
this.processDecrypted(envelope, msg).then(message => {
|
|
|
|
|
const groupId = message.group && message.group.id;
|
|
|
|
|
const isBlocked = this.isGroupBlocked(groupId);
|
|
|
|
|
const isMe = envelope.source === textsecure.storage.user.getNumber();
|
|
|
|
|
const isMe =
|
|
|
|
|
envelope.source === textsecure.storage.user.getNumber() ||
|
|
|
|
|
envelope.source === window.storage.get('primaryDevicePubKey');
|
|
|
|
|
const isLeavingGroup = Boolean(
|
|
|
|
|
message.group &&
|
|
|
|
|
message.group.type === textsecure.protobuf.GroupContext.Type.QUIT
|
|
|
|
@ -1451,13 +1453,23 @@ MessageReceiver.prototype.extend({
|
|
|
|
|
window.log.info('null message from', this.getEnvelopeId(envelope));
|
|
|
|
|
this.removeFromCache(envelope);
|
|
|
|
|
},
|
|
|
|
|
handleSyncMessage(envelope, syncMessage) {
|
|
|
|
|
if (envelope.source !== this.number) {
|
|
|
|
|
throw new Error('Received sync message from another number');
|
|
|
|
|
}
|
|
|
|
|
// eslint-disable-next-line eqeqeq
|
|
|
|
|
if (envelope.sourceDevice == this.deviceId) {
|
|
|
|
|
throw new Error('Received sync message from our own device');
|
|
|
|
|
async handleSyncMessage(envelope, syncMessage) {
|
|
|
|
|
const ourNumber = textsecure.storage.user.getNumber();
|
|
|
|
|
// NOTE: Maybe we should be caching this list?
|
|
|
|
|
const ourAuthorisations = await libloki.storage.getPrimaryDeviceMapping(
|
|
|
|
|
ourNumber
|
|
|
|
|
);
|
|
|
|
|
const validSyncSender =
|
|
|
|
|
ourAuthorisations &&
|
|
|
|
|
ourAuthorisations.some(
|
|
|
|
|
auth =>
|
|
|
|
|
auth.secondaryDevicePubKey === ourNumber ||
|
|
|
|
|
auth.primaryDevicePubKey === ourNumber
|
|
|
|
|
);
|
|
|
|
|
if (!validSyncSender) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
"Received sync message from a device we aren't paired with"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (syncMessage.sent) {
|
|
|
|
|
const sentMessage = syncMessage.sent;
|
|
|
|
|