Prevent interaction with non-Signal messages restored from backup

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
automated-signal 2024-09-03 21:58:39 -05:00 committed by GitHub
parent e935f13cca
commit 07845340dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -1892,6 +1892,7 @@ function canReplyOrReact(
| 'deletedForEveryone'
| 'payment'
| 'sendStateByConversationId'
| 'sms'
| 'type'
>,
ourConversationId: string | undefined,
@ -1930,6 +1931,10 @@ function canReplyOrReact(
return false;
}
if (message.sms) {
return false;
}
if (isOutgoing(message)) {
return (
isMessageJustForMe(sendStateByConversationId ?? {}, ourConversationId) ||
@ -1964,6 +1969,7 @@ export function canReply(
| 'conversationId'
| 'deletedForEveryone'
| 'sendStateByConversationId'
| 'sms'
| 'type'
>,
ourConversationId: string | undefined,
@ -1985,6 +1991,7 @@ export function canReact(
| 'conversationId'
| 'deletedForEveryone'
| 'sendStateByConversationId'
| 'sms'
| 'type'
>,
ourConversationId: string | undefined,
@ -2003,11 +2010,17 @@ export function canCopy(
export function canDeleteForEveryone(
message: Pick<
MessageWithUIFieldsType,
'type' | 'deletedForEveryone' | 'sent_at' | 'sendStateByConversationId'
| 'type'
| 'deletedForEveryone'
| 'sent_at'
| 'sendStateByConversationId'
| 'sms'
>,
isMe: boolean
): boolean {
return (
// Is this an SMS restored from backup?
!message.sms &&
// Is this a message I sent?
isOutgoing(message) &&
// Has the message already been deleted?

View file

@ -11,6 +11,10 @@ export const MESSAGE_MAX_EDIT_COUNT = 10;
export function canEditMessage(
message: ReadonlyMessageAttributesType
): boolean {
if (message.sms) {
return false;
}
const result =
!message.deletedForEveryone &&
isOutgoing(message) &&