Prevent interaction with non-Signal messages restored from backup
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
e935f13cca
commit
07845340dc
2 changed files with 18 additions and 1 deletions
|
@ -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?
|
||||
|
|
|
@ -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) &&
|
||||
|
|
Loading…
Reference in a new issue