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