Ensure message expire timer start times are never in the future

pull/1/head
Scott Nonnenberg 7 years ago
parent f3bd0cf903
commit 71d873ccfe

@ -720,6 +720,7 @@
function createSentMessage(data) {
const now = Date.now();
return new Whisper.Message({
source: textsecure.storage.user.getNumber(),
sourceDevice: data.device,
@ -728,7 +729,9 @@
conversationId: data.destination,
type: 'outgoing',
sent: true,
expirationStartTimestamp: data.expirationStartTimestamp,
expirationStartTimestamp: data.expirationStartTimestamp
? Math.min(data.expirationStartTimestamp, Date.now())
: null,
});
}

@ -669,7 +669,7 @@
) {
message.set(
'expirationStartTimestamp',
readSync.get('read_at')
Math.min(readSync.get('read_at'), Date.now())
);
}
}
@ -802,7 +802,8 @@
async markRead(readAt) {
this.unset('unread');
if (this.get('expireTimer') && !this.get('expirationStartTimestamp')) {
this.set('expirationStartTimestamp', readAt || Date.now());
const expireTimerStart = Math.min(Date.now(), readAt || Date.now());
this.set('expirationStartTimestamp', expireTimerStart);
}
Whisper.Notifications.remove(
Whisper.Notifications.where({

Loading…
Cancel
Save