|
|
|
@ -668,11 +668,28 @@
|
|
|
|
|
}.bind(this));
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
updateExpirationTimer: function(expireTimer, source, received_at) {
|
|
|
|
|
if (!expireTimer) { expireTimer = null; }
|
|
|
|
|
updateExpirationTimer: function(expireTimer, source, received_at, options) {
|
|
|
|
|
options = options || {};
|
|
|
|
|
_.defaults(options, {fromSync: false});
|
|
|
|
|
|
|
|
|
|
if (!expireTimer) {
|
|
|
|
|
expireTimer = null;
|
|
|
|
|
}
|
|
|
|
|
if (this.get('expireTimer') === expireTimer
|
|
|
|
|
|| (!expireTimer && !this.get('expireTimer'))) {
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(
|
|
|
|
|
'Updating expireTimer for conversation',
|
|
|
|
|
this.idForLogging(),
|
|
|
|
|
'via',
|
|
|
|
|
source
|
|
|
|
|
);
|
|
|
|
|
source = source || textsecure.storage.user.getNumber();
|
|
|
|
|
var timestamp = received_at || Date.now();
|
|
|
|
|
this.save({ expireTimer: expireTimer });
|
|
|
|
|
|
|
|
|
|
var message = this.messageCollection.add({
|
|
|
|
|
conversationId : this.id,
|
|
|
|
|
type : received_at ? 'incoming' : 'outgoing',
|
|
|
|
@ -681,7 +698,8 @@
|
|
|
|
|
flags : textsecure.protobuf.DataMessage.Flags.EXPIRATION_TIMER_UPDATE,
|
|
|
|
|
expirationTimerUpdate : {
|
|
|
|
|
expireTimer : expireTimer,
|
|
|
|
|
source : source
|
|
|
|
|
source : source,
|
|
|
|
|
fromSync : options.fromSync,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (this.isPrivate()) {
|
|
|
|
@ -690,8 +708,16 @@
|
|
|
|
|
if (message.isOutgoing()) {
|
|
|
|
|
message.set({recipients: this.getRecipients() });
|
|
|
|
|
}
|
|
|
|
|
message.save();
|
|
|
|
|
if (message.isOutgoing()) { // outgoing update, send it to the number/group
|
|
|
|
|
|
|
|
|
|
return Promise.all([
|
|
|
|
|
wrapDeferred(message.save()),
|
|
|
|
|
wrapDeferred(this.save({ expireTimer: expireTimer })),
|
|
|
|
|
]).then(function() {
|
|
|
|
|
if (message.isIncoming()) {
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// change was made locally, send it to the number/group
|
|
|
|
|
var sendFunc;
|
|
|
|
|
if (this.get('type') == 'private') {
|
|
|
|
|
sendFunc = textsecure.messaging.sendExpirationTimerUpdateToNumber;
|
|
|
|
@ -703,9 +729,16 @@
|
|
|
|
|
if (this.get('profileSharing')) {
|
|
|
|
|
profileKey = storage.get('profileKey');
|
|
|
|
|
}
|
|
|
|
|
message.send(sendFunc(this.get('id'), this.get('expireTimer'), message.get('sent_at'), profileKey));
|
|
|
|
|
}
|
|
|
|
|
var promise = sendFunc(this.get('id'),
|
|
|
|
|
this.get('expireTimer'),
|
|
|
|
|
message.get('sent_at'),
|
|
|
|
|
profileKey
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return message.send(promise).then(function() {
|
|
|
|
|
return message;
|
|
|
|
|
});
|
|
|
|
|
}.bind(this));
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
isSearchable: function() {
|
|
|
|
|