Bump up the edit send/receive timers to 24hr/48hr

This commit is contained in:
Josh Perez 2023-08-25 09:50:04 -04:00 committed by GitHub
parent 0459ab02d3
commit cc13350d3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 8 deletions

View file

@ -2390,9 +2390,9 @@ export default class MessageReceiver
}
// Timing check
if (isOlderThan(envelope.serverTimestamp, durations.DAY)) {
if (isOlderThan(envelope.serverTimestamp, durations.DAY * 2)) {
log.info(
'MessageReceiver.handleEditMessage: cannot edit message older than 24h',
'MessageReceiver.handleEditMessage: cannot edit message older than 48h',
logId,
envelope.serverTimestamp
);

View file

@ -2,21 +2,20 @@
// SPDX-License-Identifier: AGPL-3.0-only
import type { MessageAttributesType } from '../model-types.d';
import { HOUR } from './durations';
import { DAY } from './durations';
import { canEditMessages } from './canEditMessages';
import { isMoreRecentThan } from './timestamp';
import { isOutgoing } from '../messages/helpers';
import { isSent, someSendStatus } from '../messages/MessageSendState';
const MAX_EDIT_COUNT = 10;
const THREE_HOURS = 3 * HOUR;
export function canEditMessage(message: MessageAttributesType): boolean {
const result =
canEditMessages() &&
!message.deletedForEveryone &&
isOutgoing(message) &&
isMoreRecentThan(message.sent_at, THREE_HOURS) &&
isMoreRecentThan(message.sent_at, DAY) &&
(message.editHistory?.length ?? 0) <= MAX_EDIT_COUNT &&
someSendStatus(message.sendStateByConversationId, isSent) &&
Boolean(message.body);

View file

@ -66,5 +66,5 @@ function isDeletionTooOld(
const messageTimestamp =
message.get('serverTimestamp') || message.get('sent_at') || 0;
const delta = Math.abs(doe.serverTimestamp - messageTimestamp);
return delta > DAY;
return delta > DAY * 2;
}

View file

@ -84,9 +84,9 @@ export async function handleEditMessage(
if (
serverTimestamp &&
!isNoteToSelf &&
isOlderThan(serverTimestamp, durations.DAY)
isOlderThan(serverTimestamp, durations.DAY * 2)
) {
log.warn(`${idLog}: cannot edit message older than 24h`, serverTimestamp);
log.warn(`${idLog}: cannot edit message older than 48h`, serverTimestamp);
return;
}