Lets you edit note to self indefinitely
This commit is contained in:
parent
9c869148ef
commit
8410f95368
2 changed files with 32 additions and 3 deletions
|
@ -12,13 +12,27 @@ const MAX_EDIT_COUNT = 10;
|
|||
const THREE_HOURS = 3 * HOUR;
|
||||
|
||||
export function canEditMessage(message: MessageAttributesType): boolean {
|
||||
return (
|
||||
const result =
|
||||
canEditMessages() &&
|
||||
!message.deletedForEveryone &&
|
||||
isOutgoing(message) &&
|
||||
isMoreRecentThan(message.sent_at, THREE_HOURS) &&
|
||||
(message.editHistory?.length ?? 0) <= MAX_EDIT_COUNT &&
|
||||
someSendStatus(message.sendStateByConversationId, isSent) &&
|
||||
Boolean(message.body)
|
||||
);
|
||||
Boolean(message.body);
|
||||
|
||||
if (result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
message.conversationId ===
|
||||
window.ConversationController.getOurConversationId()
|
||||
) {
|
||||
return (
|
||||
canEditMessages() && !message.deletedForEveryone && Boolean(message.body)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import type {
|
|||
QuotedMessageType,
|
||||
} from '../model-types.d';
|
||||
import type { LinkPreviewType } from '../types/message/LinkPreviews';
|
||||
import * as durations from './durations';
|
||||
import * as log from '../logging/log';
|
||||
import { ReadStatus } from '../messages/MessageReadStatus';
|
||||
import dataInterface from '../sql/Client';
|
||||
|
@ -17,6 +18,7 @@ import { getAttachmentSignature, isVoiceMessage } from '../types/Attachment';
|
|||
import { getMessageIdForLogging } from './idForLogging';
|
||||
import { hasErrors } from '../state/selectors/message';
|
||||
import { isIncoming, isOutgoing } from '../messages/helpers';
|
||||
import { isOlderThan } from './timestamp';
|
||||
import { isDirectConversation } from './whatTypeOfConversation';
|
||||
import { queueAttachmentDownloads } from './queueAttachmentDownloads';
|
||||
import { shouldReplyNotifyUser } from './shouldReplyNotifyUser';
|
||||
|
@ -49,6 +51,19 @@ export async function handleEditMessage(
|
|||
return;
|
||||
}
|
||||
|
||||
const { serverTimestamp } = editAttributes.message;
|
||||
const isNoteToSelf =
|
||||
mainMessage.conversationId ===
|
||||
window.ConversationController.getOurConversationId();
|
||||
if (
|
||||
serverTimestamp &&
|
||||
!isNoteToSelf &&
|
||||
isOlderThan(serverTimestamp, durations.DAY)
|
||||
) {
|
||||
log.warn(`${idLog}: cannot edit message older than 24h`, serverTimestamp);
|
||||
return;
|
||||
}
|
||||
|
||||
const mainMessageModel = window.MessageController.register(
|
||||
mainMessage.id,
|
||||
mainMessage
|
||||
|
|
Loading…
Reference in a new issue