Remove 10-edit limit for note to self
Co-authored-by: yash-signal <yash@signal.org>
This commit is contained in:
parent
9da1685dba
commit
850b78042b
3 changed files with 26 additions and 25 deletions
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
13
ts/util/isMessageNoteToSelf.ts
Normal file
13
ts/util/isMessageNoteToSelf.ts
Normal 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()
|
||||
);
|
||||
}
|
Loading…
Reference in a new issue