Do not confirm DOE or edit until it is processed
This commit is contained in:
parent
7b6cd00b3f
commit
d8ea785f4e
12 changed files with 145 additions and 138 deletions
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { DeleteModel } from '../messageModifiers/Deletes';
|
||||
import type { DeleteAttributesType } from '../messageModifiers/Deletes';
|
||||
import type { MessageModel } from '../models/messages';
|
||||
import * as log from '../logging/log';
|
||||
import { DAY } from './durations';
|
||||
|
@ -11,7 +11,10 @@ import { isStory } from '../state/selectors/message';
|
|||
|
||||
export async function deleteForEveryone(
|
||||
message: MessageModel,
|
||||
doe: DeleteModel,
|
||||
doe: Pick<
|
||||
DeleteAttributesType,
|
||||
'fromId' | 'targetSentTimestamp' | 'serverTimestamp'
|
||||
>,
|
||||
shouldPersist = true
|
||||
): Promise<void> {
|
||||
if (isDeletionByMe(message, doe)) {
|
||||
|
@ -32,11 +35,11 @@ export async function deleteForEveryone(
|
|||
|
||||
if (isDeletionTooOld(message, doe)) {
|
||||
log.warn('Received late DOE. Dropping.', {
|
||||
fromId: doe.get('fromId'),
|
||||
targetSentTimestamp: doe.get('targetSentTimestamp'),
|
||||
fromId: doe.fromId,
|
||||
targetSentTimestamp: doe.targetSentTimestamp,
|
||||
messageServerTimestamp: message.get('serverTimestamp'),
|
||||
messageSentAt: message.get('sent_at'),
|
||||
deleteServerTimestamp: doe.get('serverTimestamp'),
|
||||
deleteServerTimestamp: doe.serverTimestamp,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -46,22 +49,22 @@ export async function deleteForEveryone(
|
|||
|
||||
function isDeletionByMe(
|
||||
message: Readonly<MessageModel>,
|
||||
doe: Readonly<DeleteModel>
|
||||
doe: Pick<DeleteAttributesType, 'fromId'>
|
||||
): boolean {
|
||||
const ourConversationId =
|
||||
window.ConversationController.getOurConversationIdOrThrow();
|
||||
return (
|
||||
getContactId(message.attributes) === ourConversationId &&
|
||||
doe.get('fromId') === ourConversationId
|
||||
doe.fromId === ourConversationId
|
||||
);
|
||||
}
|
||||
|
||||
function isDeletionTooOld(
|
||||
message: Readonly<MessageModel>,
|
||||
doe: Readonly<DeleteModel>
|
||||
doe: Pick<DeleteAttributesType, 'serverTimestamp'>
|
||||
): boolean {
|
||||
const messageTimestamp =
|
||||
message.get('serverTimestamp') || message.get('sent_at') || 0;
|
||||
const delta = Math.abs(doe.get('serverTimestamp') - messageTimestamp);
|
||||
const delta = Math.abs(doe.serverTimestamp - messageTimestamp);
|
||||
return delta > DAY;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue