From b070cd56c428a7f72f181ef2e8fb8dbac2277391 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Mon, 16 Oct 2023 10:46:11 -0700 Subject: [PATCH] Bump DOE timer from 3h to 24h Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com> --- ts/components/conversation/Message.tsx | 3 +-- ts/state/selectors/message.ts | 5 ++--- ts/test-electron/state/selectors/messages_test.ts | 2 +- ts/util/sendDeleteForEveryoneMessage.ts | 6 ++---- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index 4934f4933..ece9902f7 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -118,7 +118,6 @@ const STICKER_SIZE = 200; const GIF_SIZE = 300; // Note: this needs to match the animation time const TARGETED_TIMEOUT = 1200; -const THREE_HOURS = 3 * 60 * 60 * 1000; const SENT_STATUSES = new Set([ 'delivered', 'read', @@ -679,7 +678,7 @@ export class Message extends React.PureComponent { private getTimeRemainingForDeleteForEveryone(): number { const { timestamp } = this.props; - return Math.max(timestamp - Date.now() + THREE_HOURS, 0); + return Math.max(timestamp - Date.now() + DAY, 0); } private startDeleteForEveryoneTimerIfApplicable(): void { diff --git a/ts/state/selectors/message.ts b/ts/state/selectors/message.ts index 9497d8b90..569378821 100644 --- a/ts/state/selectors/message.ts +++ b/ts/state/selectors/message.ts @@ -116,7 +116,7 @@ import { } from '../../messages/MessageSendState'; import * as log from '../../logging/log'; import { getConversationColorAttributes } from '../../util/getConversationColorAttributes'; -import { DAY, HOUR, DurationInSeconds } from '../../util/durations'; +import { DAY, DurationInSeconds } from '../../util/durations'; import { getStoryReplyText } from '../../util/getStoryReplyText'; import type { MessageAttributesWithPaymentEvent } from '../../messages/helpers'; import { @@ -139,7 +139,6 @@ import { getCallIdFromEra } from '../../util/callDisposition'; export { isIncoming, isOutgoing, isStory }; -const THREE_HOURS = 3 * HOUR; const linkify = LinkifyIt(); type FormattedContact = Partial & @@ -1842,7 +1841,7 @@ export function canDeleteForEveryone( // Has the message already been deleted? !message.deletedForEveryone && // Is it too old to delete? - isMoreRecentThan(message.sent_at, THREE_HOURS) && + isMoreRecentThan(message.sent_at, DAY) && // Is it sent to anyone? someSendStatus(message.sendStateByConversationId, isSent) ); diff --git a/ts/test-electron/state/selectors/messages_test.ts b/ts/test-electron/state/selectors/messages_test.ts index eef851843..bfd185acd 100644 --- a/ts/test-electron/state/selectors/messages_test.ts +++ b/ts/test-electron/state/selectors/messages_test.ts @@ -100,7 +100,7 @@ describe('state/selectors/messages', () => { it('returns false for messages that were are too old to delete', () => { const message = { type: 'outgoing' as const, - sent_at: Date.now() - moment.duration(4, 'hours').asMilliseconds(), + sent_at: Date.now() - moment.duration(25, 'hours').asMilliseconds(), sendStateByConversationId: { [ourConversationId]: { status: SendStatus.Read, diff --git a/ts/util/sendDeleteForEveryoneMessage.ts b/ts/util/sendDeleteForEveryoneMessage.ts index 73be82b54..9d118d405 100644 --- a/ts/util/sendDeleteForEveryoneMessage.ts +++ b/ts/util/sendDeleteForEveryoneMessage.ts @@ -4,7 +4,7 @@ import type { ConversationAttributesType } from '../model-types.d'; import type { ConversationQueueJobData } from '../jobs/conversationJobQueue'; import * as Errors from '../types/errors'; -import * as durations from './durations'; +import { DAY } from './durations'; import * as log from '../logging/log'; import { conversationJobQueue, @@ -20,8 +20,6 @@ import { getRecipientConversationIds } from './getRecipientConversationIds'; import { getRecipients } from './getRecipients'; import { repeat, zipObject } from './iterables'; -const THREE_HOURS = durations.HOUR * 3; - export async function sendDeleteForEveryoneMessage( conversationAttributes: ConversationAttributesType, options: { @@ -42,7 +40,7 @@ export async function sendDeleteForEveryoneMessage( const idForLogging = getMessageIdForLogging(message.attributes); const timestamp = Date.now(); - const maxDuration = deleteForEveryoneDuration || THREE_HOURS; + const maxDuration = deleteForEveryoneDuration || DAY; if (timestamp - targetTimestamp > maxDuration) { throw new Error(`Cannot send DOE for a message older than ${maxDuration}`); }