|
|
@ -16,6 +16,7 @@ import { ECKeyPair } from './keypairs';
|
|
|
|
import { handleConfigurationMessage } from './configMessage';
|
|
|
|
import { handleConfigurationMessage } from './configMessage';
|
|
|
|
import { ConversationTypeEnum } from '../models/conversation';
|
|
|
|
import { ConversationTypeEnum } from '../models/conversation';
|
|
|
|
import { removeMessagePadding } from '../session/crypto/BufferPadding';
|
|
|
|
import { removeMessagePadding } from '../session/crypto/BufferPadding';
|
|
|
|
|
|
|
|
import { perfEnd, perfStart } from '../session/utils/Performamce';
|
|
|
|
|
|
|
|
|
|
|
|
export async function handleContentMessage(envelope: EnvelopePlus) {
|
|
|
|
export async function handleContentMessage(envelope: EnvelopePlus) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -300,9 +301,14 @@ export async function innerHandleContentMessage(
|
|
|
|
plaintext: ArrayBuffer
|
|
|
|
plaintext: ArrayBuffer
|
|
|
|
): Promise<void> {
|
|
|
|
): Promise<void> {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
perfStart(`SignalService.Content.decode-${envelope.id}`);
|
|
|
|
|
|
|
|
|
|
|
|
const content = SignalService.Content.decode(new Uint8Array(plaintext));
|
|
|
|
const content = SignalService.Content.decode(new Uint8Array(plaintext));
|
|
|
|
|
|
|
|
perfEnd(`SignalService.Content.decode-${envelope.id}`, 'SignalService.Content.decode');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
perfStart(`isBlocked-${envelope.id}`);
|
|
|
|
const blocked = await isBlocked(envelope.source);
|
|
|
|
const blocked = await isBlocked(envelope.source);
|
|
|
|
|
|
|
|
perfEnd(`isBlocked-${envelope.id}`, 'isBlocked');
|
|
|
|
if (blocked) {
|
|
|
|
if (blocked) {
|
|
|
|
// We want to allow a blocked user message if that's a control message for a known group and the group is not blocked
|
|
|
|
// We want to allow a blocked user message if that's a control message for a known group and the group is not blocked
|
|
|
|
if (shouldDropBlockedUserMessage(content)) {
|
|
|
|
if (shouldDropBlockedUserMessage(content)) {
|
|
|
@ -322,16 +328,24 @@ export async function innerHandleContentMessage(
|
|
|
|
if (content.dataMessage.profileKey && content.dataMessage.profileKey.length === 0) {
|
|
|
|
if (content.dataMessage.profileKey && content.dataMessage.profileKey.length === 0) {
|
|
|
|
content.dataMessage.profileKey = null;
|
|
|
|
content.dataMessage.profileKey = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
perfStart(`handleDataMessage-${envelope.id}`);
|
|
|
|
await handleDataMessage(envelope, content.dataMessage);
|
|
|
|
await handleDataMessage(envelope, content.dataMessage);
|
|
|
|
|
|
|
|
perfEnd(`handleDataMessage-${envelope.id}`, 'handleDataMessage');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (content.receiptMessage) {
|
|
|
|
if (content.receiptMessage) {
|
|
|
|
|
|
|
|
perfStart(`handleReceiptMessage-${envelope.id}`);
|
|
|
|
|
|
|
|
|
|
|
|
await handleReceiptMessage(envelope, content.receiptMessage);
|
|
|
|
await handleReceiptMessage(envelope, content.receiptMessage);
|
|
|
|
|
|
|
|
perfEnd(`handleReceiptMessage-${envelope.id}`, 'handleReceiptMessage');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (content.typingMessage) {
|
|
|
|
if (content.typingMessage) {
|
|
|
|
|
|
|
|
perfStart(`handleTypingMessage-${envelope.id}`);
|
|
|
|
|
|
|
|
|
|
|
|
await handleTypingMessage(envelope, content.typingMessage as SignalService.TypingMessage);
|
|
|
|
await handleTypingMessage(envelope, content.typingMessage as SignalService.TypingMessage);
|
|
|
|
|
|
|
|
perfEnd(`handleTypingMessage-${envelope.id}`, 'handleTypingMessage');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (content.configurationMessage) {
|
|
|
|
if (content.configurationMessage) {
|
|
|
@ -343,10 +357,16 @@ export async function innerHandleContentMessage(
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (content.dataExtractionNotification) {
|
|
|
|
if (content.dataExtractionNotification) {
|
|
|
|
|
|
|
|
perfStart(`handleDataExtractionNotification-${envelope.id}`);
|
|
|
|
|
|
|
|
|
|
|
|
await handleDataExtractionNotification(
|
|
|
|
await handleDataExtractionNotification(
|
|
|
|
envelope,
|
|
|
|
envelope,
|
|
|
|
content.dataExtractionNotification as SignalService.DataExtractionNotification
|
|
|
|
content.dataExtractionNotification as SignalService.DataExtractionNotification
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
perfEnd(
|
|
|
|
|
|
|
|
`handleDataExtractionNotification-${envelope.id}`,
|
|
|
|
|
|
|
|
'handleDataExtractionNotification'
|
|
|
|
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|