Sync expirationStartTimestamp on outgoing messages
Linked devices need to know when to start the clock.
This commit is contained in:
parent
6074a29046
commit
ad2174e279
3 changed files with 13 additions and 5 deletions
|
@ -38996,7 +38996,7 @@ MessageSender.prototype = {
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
sendSyncMessage: function(encodedDataMessage, timestamp, destination) {
|
sendSyncMessage: function(encodedDataMessage, timestamp, destination, expirationStartTimestamp) {
|
||||||
var myNumber = textsecure.storage.user.getNumber();
|
var myNumber = textsecure.storage.user.getNumber();
|
||||||
var myDevice = textsecure.storage.user.getDeviceId();
|
var myDevice = textsecure.storage.user.getDeviceId();
|
||||||
if (myDevice == 1) {
|
if (myDevice == 1) {
|
||||||
|
@ -39010,6 +39010,9 @@ MessageSender.prototype = {
|
||||||
if (destination) {
|
if (destination) {
|
||||||
sentMessage.destination = destination;
|
sentMessage.destination = destination;
|
||||||
}
|
}
|
||||||
|
if (expirationStartTimestamp) {
|
||||||
|
sentMessage.expirationStartTimestamp = expirationStartTimestamp;
|
||||||
|
}
|
||||||
var syncMessage = new textsecure.protobuf.SyncMessage();
|
var syncMessage = new textsecure.protobuf.SyncMessage();
|
||||||
syncMessage.sent = sentMessage;
|
syncMessage.sent = sentMessage;
|
||||||
var contentMessage = new textsecure.protobuf.Content();
|
var contentMessage = new textsecure.protobuf.Content();
|
||||||
|
|
|
@ -155,13 +155,15 @@
|
||||||
send: function(promise) {
|
send: function(promise) {
|
||||||
this.trigger('pending');
|
this.trigger('pending');
|
||||||
return promise.then(function(result) {
|
return promise.then(function(result) {
|
||||||
|
var now = Date.now();
|
||||||
this.trigger('done');
|
this.trigger('done');
|
||||||
if (result.dataMessage) {
|
if (result.dataMessage) {
|
||||||
this.set({dataMessage: result.dataMessage});
|
this.set({dataMessage: result.dataMessage});
|
||||||
}
|
}
|
||||||
this.save({sent: true});
|
this.save({sent: true, expirationStartTimestamp: now});
|
||||||
this.sendSyncMessage();
|
this.sendSyncMessage();
|
||||||
}.bind(this)).catch(function(result) {
|
}.bind(this)).catch(function(result) {
|
||||||
|
var now = Date.now();
|
||||||
this.trigger('done');
|
this.trigger('done');
|
||||||
if (result.dataMessage) {
|
if (result.dataMessage) {
|
||||||
this.set({dataMessage: result.dataMessage});
|
this.set({dataMessage: result.dataMessage});
|
||||||
|
@ -172,7 +174,7 @@
|
||||||
} else {
|
} else {
|
||||||
this.saveErrors(result.errors);
|
this.saveErrors(result.errors);
|
||||||
if (result.successfulNumbers.length > 0) {
|
if (result.successfulNumbers.length > 0) {
|
||||||
this.set({sent: true});
|
this.set({sent: true, expirationStartTimestamp: now});
|
||||||
this.sendSyncMessage();
|
this.sendSyncMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,7 +190,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return textsecure.messaging.sendSyncMessage(
|
return textsecure.messaging.sendSyncMessage(
|
||||||
dataMessage, this.get('sent_at'), this.get('destination')
|
dataMessage, this.get('sent_at'), this.get('destination'), this.get('expirationStartTimestamp')
|
||||||
).then(function() {
|
).then(function() {
|
||||||
this.save({synced: true, dataMessage: null});
|
this.save({synced: true, dataMessage: null});
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
|
@ -203,7 +203,7 @@ MessageSender.prototype = {
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
sendSyncMessage: function(encodedDataMessage, timestamp, destination) {
|
sendSyncMessage: function(encodedDataMessage, timestamp, destination, expirationStartTimestamp) {
|
||||||
var myNumber = textsecure.storage.user.getNumber();
|
var myNumber = textsecure.storage.user.getNumber();
|
||||||
var myDevice = textsecure.storage.user.getDeviceId();
|
var myDevice = textsecure.storage.user.getDeviceId();
|
||||||
if (myDevice == 1) {
|
if (myDevice == 1) {
|
||||||
|
@ -217,6 +217,9 @@ MessageSender.prototype = {
|
||||||
if (destination) {
|
if (destination) {
|
||||||
sentMessage.destination = destination;
|
sentMessage.destination = destination;
|
||||||
}
|
}
|
||||||
|
if (expirationStartTimestamp) {
|
||||||
|
sentMessage.expirationStartTimestamp = expirationStartTimestamp;
|
||||||
|
}
|
||||||
var syncMessage = new textsecure.protobuf.SyncMessage();
|
var syncMessage = new textsecure.protobuf.SyncMessage();
|
||||||
syncMessage.sent = sentMessage;
|
syncMessage.sent = sentMessage;
|
||||||
var contentMessage = new textsecure.protobuf.Content();
|
var contentMessage = new textsecure.protobuf.Content();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue