Remove 10-edit limit for note to self

Co-authored-by: yash-signal <yash@signal.org>
This commit is contained in:
automated-signal 2024-10-15 15:14:53 -05:00 committed by GitHub
parent 9da1685dba
commit 850b78042b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 25 deletions

View file

@ -5,38 +5,27 @@ import type { ReadonlyMessageAttributesType } from '../model-types.d';
import { DAY } from './durations';
import { isMoreRecentThan } from './timestamp';
import { isOutgoing } from '../messages/helpers';
import { isMessageNoteToSelf } from './isMessageNoteToSelf';
export const MESSAGE_MAX_EDIT_COUNT = 10;
export function canEditMessage(
message: ReadonlyMessageAttributesType
): boolean {
if (message.sms) {
return false;
}
const result =
return (
!message.sms &&
!message.deletedForEveryone &&
isOutgoing(message) &&
isMoreRecentThan(message.sent_at, DAY) &&
Boolean(message.body);
if (result) {
return true;
}
if (
message.conversationId ===
window.ConversationController.getOurConversationId()
) {
return !message.deletedForEveryone && Boolean(message.body);
}
return false;
(isMoreRecentThan(message.sent_at, DAY) || isMessageNoteToSelf(message)) &&
Boolean(message.body)
);
}
export function isWithinMaxEdits(
message: ReadonlyMessageAttributesType
): boolean {
return (message.editHistory?.length ?? 0) <= MESSAGE_MAX_EDIT_COUNT;
return (
isMessageNoteToSelf(message) ||
(message.editHistory?.length ?? 0) <= MESSAGE_MAX_EDIT_COUNT
);
}

View file

@ -24,6 +24,7 @@ import { isDirectConversation } from './whatTypeOfConversation';
import { isTooOldToModifyMessage } from './isTooOldToModifyMessage';
import { queueAttachmentDownloads } from './queueAttachmentDownloads';
import { modifyTargetMessage } from './modifyTargetMessage';
import { isMessageNoteToSelf } from './isMessageNoteToSelf';
const RECURSION_LIMIT = 15;
@ -92,12 +93,10 @@ export async function handleEditMessage(
}
const { serverTimestamp } = editAttributes.message;
const isNoteToSelf =
mainMessage.conversationId ===
window.ConversationController.getOurConversationId();
if (
serverTimestamp &&
!isNoteToSelf &&
!isMessageNoteToSelf(mainMessage) &&
isTooOldToModifyMessage(serverTimestamp, mainMessage)
) {
log.warn(`${idLog}: cannot edit message older than 48h`, serverTimestamp);

View file

@ -0,0 +1,13 @@
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { ReadonlyMessageAttributesType } from '../model-types.d';
export function isMessageNoteToSelf(
message: Pick<ReadonlyMessageAttributesType, 'conversationId'>
): boolean {
return (
message.conversationId ===
window.ConversationController.getOurConversationId()
);
}