Skip to content

Commit

Permalink
Fallback to sent_at when serverTimestamp is empty
Browse files Browse the repository at this point in the history
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
  • Loading branch information
automated-signal and indutny-signal committed Aug 13, 2021
1 parent f482665 commit 8b03547
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ts/util/deleteForEveryone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8b03547

Please sign in to comment.