Always allow 'Note To Self' deletions regardless of time

This commit is contained in:
Wes Appler 2023-11-26 17:22:56 -05:00
parent ab187ab265
commit 842566a34f
2 changed files with 9 additions and 5 deletions

View file

@ -19,6 +19,7 @@ import { __DEPRECATED$getMessageById } from '../messages/getMessageById';
import { getRecipientConversationIds } from './getRecipientConversationIds';
import { getRecipients } from './getRecipients';
import { repeat, zipObject } from './iterables';
import { isMe } from './whatTypeOfConversation';
export async function sendDeleteForEveryoneMessage(
conversationAttributes: ConversationAttributesType,
@ -39,10 +40,13 @@ export async function sendDeleteForEveryoneMessage(
}
const idForLogging = getMessageIdForLogging(message.attributes);
const timestamp = Date.now();
const maxDuration = deleteForEveryoneDuration || DAY;
if (timestamp - targetTimestamp > maxDuration) {
throw new Error(`Cannot send DOE for a message older than ${maxDuration}`);
// If conversation is a Note To Self, no deletion time limits apply.
if (!isMe(conversationAttributes)) {
const timestamp = Date.now();
const maxDuration = deleteForEveryoneDuration || DAY;
if (timestamp - targetTimestamp > maxDuration) {
throw new Error(`Cannot send DOE for a message older than ${maxDuration}`);
}
}
message.set({