Lets you edit note to self indefinitely
This commit is contained in:
@@ -12,13 +12,27 @@ const MAX_EDIT_COUNT = 10;
|
|||||||
const THREE_HOURS = 3 * HOUR;
|
const THREE_HOURS = 3 * HOUR;
|
||||||
|
|
||||||
export function canEditMessage(message: MessageAttributesType): boolean {
|
export function canEditMessage(message: MessageAttributesType): boolean {
|
||||||
return (
|
const result =
|
||||||
canEditMessages() &&
|
canEditMessages() &&
|
||||||
!message.deletedForEveryone &&
|
!message.deletedForEveryone &&
|
||||||
isOutgoing(message) &&
|
isOutgoing(message) &&
|
||||||
isMoreRecentThan(message.sent_at, THREE_HOURS) &&
|
isMoreRecentThan(message.sent_at, THREE_HOURS) &&
|
||||||
(message.editHistory?.length ?? 0) <= MAX_EDIT_COUNT &&
|
(message.editHistory?.length ?? 0) <= MAX_EDIT_COUNT &&
|
||||||
someSendStatus(message.sendStateByConversationId, isSent) &&
|
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,
|
QuotedMessageType,
|
||||||
} from '../model-types.d';
|
} from '../model-types.d';
|
||||||
import type { LinkPreviewType } from '../types/message/LinkPreviews';
|
import type { LinkPreviewType } from '../types/message/LinkPreviews';
|
||||||
|
import * as durations from './durations';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { ReadStatus } from '../messages/MessageReadStatus';
|
import { ReadStatus } from '../messages/MessageReadStatus';
|
||||||
import dataInterface from '../sql/Client';
|
import dataInterface from '../sql/Client';
|
||||||
@@ -17,6 +18,7 @@ import { getAttachmentSignature, isVoiceMessage } from '../types/Attachment';
|
|||||||
import { getMessageIdForLogging } from './idForLogging';
|
import { getMessageIdForLogging } from './idForLogging';
|
||||||
import { hasErrors } from '../state/selectors/message';
|
import { hasErrors } from '../state/selectors/message';
|
||||||
import { isIncoming, isOutgoing } from '../messages/helpers';
|
import { isIncoming, isOutgoing } from '../messages/helpers';
|
||||||
|
import { isOlderThan } from './timestamp';
|
||||||
import { isDirectConversation } from './whatTypeOfConversation';
|
import { isDirectConversation } from './whatTypeOfConversation';
|
||||||
import { queueAttachmentDownloads } from './queueAttachmentDownloads';
|
import { queueAttachmentDownloads } from './queueAttachmentDownloads';
|
||||||
import { shouldReplyNotifyUser } from './shouldReplyNotifyUser';
|
import { shouldReplyNotifyUser } from './shouldReplyNotifyUser';
|
||||||
@@ -49,6 +51,19 @@ export async function handleEditMessage(
|
|||||||
return;
|
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(
|
const mainMessageModel = window.MessageController.register(
|
||||||
mainMessage.id,
|
mainMessage.id,
|
||||||
mainMessage
|
mainMessage
|
||||||
|
Reference in New Issue
Block a user