diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 01e2f6cf91..49bc4d91e7 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -1304,6 +1304,15 @@ MessageReceiver.prototype.extend({ // Note that messages may (generally) only perform one action and we ignore remaining // fields after the first action. + const TIMESTAMP_VALIDATION = false; + if (TIMESTAMP_VALIDATION && envelope.timestamp !== decrypted.timestamp) { + throw new Error( + `Timestamp ${ + decrypted.timestamp + } in DataMessage did not match envelope timestamp ${envelope.timestamp}` + ); + } + if (decrypted.flags == null) { decrypted.flags = 0; } diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 9490f9f199..75c48a80fb 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -98,10 +98,13 @@ Message.prototype = { return this.dataMessage; } const proto = new textsecure.protobuf.DataMessage(); + + proto.timestamp = this.timestamp; + proto.attachments = this.attachmentPointers; + if (this.body) { proto.body = this.body; } - proto.attachments = this.attachmentPointers; if (this.flags) { proto.flags = this.flags; } @@ -154,7 +157,6 @@ Message.prototype = { if (this.expireTimer) { proto.expireTimer = this.expireTimer; } - if (this.profileKey) { proto.profileKey = this.profileKey; } @@ -535,7 +537,7 @@ MessageSender.prototype = { return this.sendIndividualProto( myNumber, contentMessage, - Date.now(), + timestamp, silent, options );