Don't do any additional processing of unsupported messages
This commit is contained in:
parent
3aba4d0d06
commit
f9b01f007f
1 changed files with 215 additions and 207 deletions
|
@ -1871,6 +1871,62 @@
|
|||
|
||||
try {
|
||||
const now = new Date().getTime();
|
||||
|
||||
const urls = window.Signal.LinkPreviews.findLinks(dataMessage.body);
|
||||
const incomingPreview = dataMessage.preview || [];
|
||||
const preview = incomingPreview.filter(
|
||||
item =>
|
||||
(item.image || item.title) &&
|
||||
urls.includes(item.url) &&
|
||||
window.Signal.LinkPreviews.isLinkInWhitelist(item.url)
|
||||
);
|
||||
if (preview.length < incomingPreview.length) {
|
||||
window.log.info(
|
||||
`${message.idForLogging()}: Eliminated ${preview.length -
|
||||
incomingPreview.length} previews with invalid urls'`
|
||||
);
|
||||
}
|
||||
|
||||
message.set({
|
||||
id: window.getGuid(),
|
||||
attachments: dataMessage.attachments,
|
||||
body: dataMessage.body,
|
||||
contact: dataMessage.contact,
|
||||
conversationId: conversation.id,
|
||||
decrypted_at: now,
|
||||
errors: [],
|
||||
flags: dataMessage.flags,
|
||||
hasAttachments: dataMessage.hasAttachments,
|
||||
hasFileAttachments: dataMessage.hasFileAttachments,
|
||||
hasVisualMediaAttachments: dataMessage.hasVisualMediaAttachments,
|
||||
isViewOnce: Boolean(dataMessage.isViewOnce),
|
||||
preview,
|
||||
requiredProtocolVersion:
|
||||
dataMessage.requiredProtocolVersion ||
|
||||
this.INITIAL_PROTOCOL_VERSION,
|
||||
supportedVersionAtReceive: this.CURRENT_PROTOCOL_VERSION,
|
||||
quote: dataMessage.quote,
|
||||
schemaVersion: dataMessage.schemaVersion,
|
||||
sticker: dataMessage.sticker,
|
||||
});
|
||||
|
||||
const conversationTimestamp = conversation.get('timestamp');
|
||||
if (
|
||||
!conversationTimestamp ||
|
||||
message.get('sent_at') > conversationTimestamp
|
||||
) {
|
||||
conversation.set({
|
||||
lastMessage: message.getNotificationText(),
|
||||
timestamp: message.get('sent_at'),
|
||||
});
|
||||
}
|
||||
|
||||
const isSupported = !message.isUnsupportedMessage();
|
||||
if (!isSupported) {
|
||||
await message.eraseContents();
|
||||
}
|
||||
|
||||
if (isSupported) {
|
||||
let attributes = {
|
||||
...conversation.attributes,
|
||||
};
|
||||
|
@ -1925,43 +1981,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
const urls = window.Signal.LinkPreviews.findLinks(dataMessage.body);
|
||||
const incomingPreview = dataMessage.preview || [];
|
||||
const preview = incomingPreview.filter(
|
||||
item =>
|
||||
(item.image || item.title) &&
|
||||
urls.includes(item.url) &&
|
||||
window.Signal.LinkPreviews.isLinkInWhitelist(item.url)
|
||||
);
|
||||
if (preview.length < incomingPreview.length) {
|
||||
window.log.info(
|
||||
`${message.idForLogging()}: Eliminated ${preview.length -
|
||||
incomingPreview.length} previews with invalid urls'`
|
||||
);
|
||||
}
|
||||
|
||||
message.set({
|
||||
id: window.getGuid(),
|
||||
attachments: dataMessage.attachments,
|
||||
body: dataMessage.body,
|
||||
contact: dataMessage.contact,
|
||||
conversationId: conversation.id,
|
||||
decrypted_at: now,
|
||||
errors: [],
|
||||
flags: dataMessage.flags,
|
||||
hasAttachments: dataMessage.hasAttachments,
|
||||
hasFileAttachments: dataMessage.hasFileAttachments,
|
||||
hasVisualMediaAttachments: dataMessage.hasVisualMediaAttachments,
|
||||
isViewOnce: Boolean(dataMessage.isViewOnce),
|
||||
preview,
|
||||
requiredProtocolVersion:
|
||||
dataMessage.requiredProtocolVersion ||
|
||||
this.INITIAL_PROTOCOL_VERSION,
|
||||
supportedVersionAtReceive: this.CURRENT_PROTOCOL_VERSION,
|
||||
quote: dataMessage.quote,
|
||||
schemaVersion: dataMessage.schemaVersion,
|
||||
sticker: dataMessage.sticker,
|
||||
});
|
||||
if (type === 'outgoing') {
|
||||
const receipts = Whisper.DeliveryReceipts.forMessage(
|
||||
conversation,
|
||||
|
@ -2006,7 +2025,9 @@
|
|||
|
||||
if (!message.isEndSession()) {
|
||||
if (dataMessage.expireTimer) {
|
||||
if (dataMessage.expireTimer !== conversation.get('expireTimer')) {
|
||||
if (
|
||||
dataMessage.expireTimer !== conversation.get('expireTimer')
|
||||
) {
|
||||
conversation.updateExpirationTimer(
|
||||
dataMessage.expireTimer,
|
||||
source,
|
||||
|
@ -2070,7 +2091,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
// A sync'd message to ourself is automatically considered read and delivered
|
||||
// A sync'd message to ourself is automatically considered read/delivered
|
||||
if (conversation.isMe()) {
|
||||
message.set({
|
||||
read_by: conversation.getRecipients(),
|
||||
|
@ -2081,17 +2102,6 @@
|
|||
message.set({ recipients: conversation.getRecipients() });
|
||||
}
|
||||
|
||||
const conversationTimestamp = conversation.get('timestamp');
|
||||
if (
|
||||
!conversationTimestamp ||
|
||||
message.get('sent_at') > conversationTimestamp
|
||||
) {
|
||||
conversation.set({
|
||||
lastMessage: message.getNotificationText(),
|
||||
timestamp: message.get('sent_at'),
|
||||
});
|
||||
}
|
||||
|
||||
if (dataMessage.profileKey) {
|
||||
const profileKey = dataMessage.profileKey.toString('base64');
|
||||
if (source === textsecure.storage.user.getNumber()) {
|
||||
|
@ -2099,11 +2109,12 @@
|
|||
} else if (conversation.isPrivate()) {
|
||||
conversation.setProfileKey(profileKey);
|
||||
} else {
|
||||
ConversationController.getOrCreateAndWait(source, 'private').then(
|
||||
sender => {
|
||||
ConversationController.getOrCreateAndWait(
|
||||
source,
|
||||
'private'
|
||||
).then(sender => {
|
||||
sender.setProfileKey(profileKey);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2131,6 +2142,7 @@
|
|||
await Whisper.ViewSyncs.onSync(viewSync);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MessageController.register(message.id, message);
|
||||
window.Signal.Data.updateConversation(
|
||||
|
@ -2138,10 +2150,6 @@
|
|||
conversation.attributes
|
||||
);
|
||||
|
||||
if (message.isUnsupportedMessage()) {
|
||||
await message.eraseContents();
|
||||
}
|
||||
|
||||
await message.queueAttachmentDownloads();
|
||||
await window.Signal.Data.saveMessage(message.attributes, {
|
||||
Message: Whisper.Message,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue