Skip to content

Commit

Permalink
Merge #6689
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Dec 4, 2023
2 parents de172b5 + 11082a3 commit ad85b17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ts/components/DeleteMessagesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function DeleteMessagesModal({
: i18n('icu:DeleteMessagesModal--deleteForMe'),
});

if (canDeleteForEveryone) {
if (canDeleteForEveryone || isMe) {
const tooManyMessages = messageCount > MAX_DELETE_FOR_EVERYONE;
actions.push({
'aria-disabled': tooManyMessages,
Expand Down
14 changes: 10 additions & 4 deletions ts/util/sendDeleteForEveryoneMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -39,10 +40,15 @@ 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({
Expand Down

0 comments on commit ad85b17

Please sign in to comment.