diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 1a01c446..2f347c07 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -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); + }); }); } diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 25838698..c4628536 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -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); + }); }); }