Fallback to sent_at when serverTimestamp is empty

This commit is contained in:
Fedor Indutny 2021-08-13 09:02:28 -07:00 committed by GitHub
parent b7447cda29
commit b2e2e6d8eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -11,16 +11,19 @@ export async function deleteForEveryone(
doe: DeleteModel,
shouldPersist = true
): Promise<void> {
const messageTimestamp =
message.get('serverTimestamp') || message.get('sent_at') || 0;
// Make sure the server timestamps for the DOE and the matching message
// are less than one day apart
const delta = Math.abs(
doe.get('serverTimestamp') - (message.get('serverTimestamp') || 0)
);
const delta = Math.abs(doe.get('serverTimestamp') - messageTimestamp);
if (delta > ONE_DAY) {
window.log.info('Received late DOE. Dropping.', {
fromId: doe.get('fromId'),
targetSentTimestamp: doe.get('targetSentTimestamp'),
messageServerTimestamp: message.get('serverTimestamp'),
messageSentAt: message.get('sent_at'),
deleteServerTimestamp: doe.get('serverTimestamp'),
});
return;