Sync outgoing messages
When sending an constrct a copy of the PushMessageContent protobuf, add a SyncMessageContext, and send it to ourselves. Do this for all kinds of group messages, and individual text/media messages, but not closeSession messages as the latter are device-specific. Do not sync messages if we are the primary device, which should only be supported in development. Normal web clients must be paired with a android or ios master device, and even in dev, a primary/standalone web client does not support linking additional devices.
This commit is contained in:
parent
94c94eb7c9
commit
40351fcc54
2 changed files with 36 additions and 2 deletions
|
@ -17102,6 +17102,19 @@ window.textsecure.messaging = function() {
|
|||
});
|
||||
}
|
||||
|
||||
var sendSyncMessage = function(message, timestamp, destination) {
|
||||
var numberDevice = textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"));
|
||||
var myNumber = numberDevice[0];
|
||||
var myDevice = numberDevice[1];
|
||||
if (myDevice != 1) {
|
||||
var sync_message = textsecure.protobuf.PushMessageContent.decode(message.encode());
|
||||
sync_message.sync = new textsecure.protobuf.PushMessageContent.SyncMessageContext();
|
||||
sync_message.sync.destination = destination;
|
||||
sync_message.sync.timestamp = timestamp;
|
||||
return sendIndividualProto(myNumber, sync_message, Date.now());
|
||||
}
|
||||
}
|
||||
|
||||
var sendGroupProto = function(numbers, proto, timestamp) {
|
||||
timestamp = timestamp || Date.now();
|
||||
var me = textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0];
|
||||
|
@ -17114,6 +17127,8 @@ window.textsecure.messaging = function() {
|
|||
else
|
||||
resolve();
|
||||
});
|
||||
}).then(function() {
|
||||
return sendSyncMessage(proto, timestamp, getString(proto.group.id));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -17126,7 +17141,9 @@ window.textsecure.messaging = function() {
|
|||
promises.push(makeAttachmentPointer(attachments[i]));
|
||||
return Promise.all(promises).then(function(attachmentsArray) {
|
||||
proto.attachments = attachmentsArray;
|
||||
return sendIndividualProto(number, proto, timestamp);
|
||||
return sendIndividualProto(number, proto, timestamp).then(function() {
|
||||
return sendSyncMessage(proto, timestamp, number);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -261,6 +261,19 @@ window.textsecure.messaging = function() {
|
|||
});
|
||||
}
|
||||
|
||||
var sendSyncMessage = function(message, timestamp, destination) {
|
||||
var numberDevice = textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"));
|
||||
var myNumber = numberDevice[0];
|
||||
var myDevice = numberDevice[1];
|
||||
if (myDevice != 1) {
|
||||
var sync_message = textsecure.protobuf.PushMessageContent.decode(message.encode());
|
||||
sync_message.sync = new textsecure.protobuf.PushMessageContent.SyncMessageContext();
|
||||
sync_message.sync.destination = destination;
|
||||
sync_message.sync.timestamp = timestamp;
|
||||
return sendIndividualProto(myNumber, sync_message, Date.now());
|
||||
}
|
||||
}
|
||||
|
||||
var sendGroupProto = function(numbers, proto, timestamp) {
|
||||
timestamp = timestamp || Date.now();
|
||||
var me = textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0];
|
||||
|
@ -273,6 +286,8 @@ window.textsecure.messaging = function() {
|
|||
else
|
||||
resolve();
|
||||
});
|
||||
}).then(function() {
|
||||
return sendSyncMessage(proto, timestamp, getString(proto.group.id));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -285,7 +300,9 @@ window.textsecure.messaging = function() {
|
|||
promises.push(makeAttachmentPointer(attachments[i]));
|
||||
return Promise.all(promises).then(function(attachmentsArray) {
|
||||
proto.attachments = attachmentsArray;
|
||||
return sendIndividualProto(number, proto, timestamp);
|
||||
return sendIndividualProto(number, proto, timestamp).then(function() {
|
||||
return sendSyncMessage(proto, timestamp, number);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue