Set timestamps in dataMessage, prepare for validation
This commit is contained in:
parent
0bc5ae5569
commit
089a232a60
2 changed files with 14 additions and 3 deletions
|
@ -1304,6 +1304,15 @@ MessageReceiver.prototype.extend({
|
||||||
// Note that messages may (generally) only perform one action and we ignore remaining
|
// Note that messages may (generally) only perform one action and we ignore remaining
|
||||||
// fields after the first action.
|
// 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) {
|
if (decrypted.flags == null) {
|
||||||
decrypted.flags = 0;
|
decrypted.flags = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,10 +98,13 @@ Message.prototype = {
|
||||||
return this.dataMessage;
|
return this.dataMessage;
|
||||||
}
|
}
|
||||||
const proto = new textsecure.protobuf.DataMessage();
|
const proto = new textsecure.protobuf.DataMessage();
|
||||||
|
|
||||||
|
proto.timestamp = this.timestamp;
|
||||||
|
proto.attachments = this.attachmentPointers;
|
||||||
|
|
||||||
if (this.body) {
|
if (this.body) {
|
||||||
proto.body = this.body;
|
proto.body = this.body;
|
||||||
}
|
}
|
||||||
proto.attachments = this.attachmentPointers;
|
|
||||||
if (this.flags) {
|
if (this.flags) {
|
||||||
proto.flags = this.flags;
|
proto.flags = this.flags;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +157,6 @@ Message.prototype = {
|
||||||
if (this.expireTimer) {
|
if (this.expireTimer) {
|
||||||
proto.expireTimer = this.expireTimer;
|
proto.expireTimer = this.expireTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.profileKey) {
|
if (this.profileKey) {
|
||||||
proto.profileKey = this.profileKey;
|
proto.profileKey = this.profileKey;
|
||||||
}
|
}
|
||||||
|
@ -535,7 +537,7 @@ MessageSender.prototype = {
|
||||||
return this.sendIndividualProto(
|
return this.sendIndividualProto(
|
||||||
myNumber,
|
myNumber,
|
||||||
contentMessage,
|
contentMessage,
|
||||||
Date.now(),
|
timestamp,
|
||||||
silent,
|
silent,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue