|
|
|
@ -388,81 +388,83 @@ export async function innerHandleContentMessage(
|
|
|
|
|
plaintext: ArrayBuffer
|
|
|
|
|
): Promise<void> {
|
|
|
|
|
const { ConversationController } = window;
|
|
|
|
|
|
|
|
|
|
const content = SignalService.Content.decode(new Uint8Array(plaintext));
|
|
|
|
|
|
|
|
|
|
const blocked = await isBlocked(envelope.source);
|
|
|
|
|
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
|
|
|
|
|
if (shouldDropBlockedUserMessage(content)) {
|
|
|
|
|
window.log.info('Dropping blocked user message');
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
window.log.info('Allowing group-control message only from blocked user');
|
|
|
|
|
try {
|
|
|
|
|
const content = SignalService.Content.decode(new Uint8Array(plaintext));
|
|
|
|
|
|
|
|
|
|
const blocked = await isBlocked(envelope.source);
|
|
|
|
|
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
|
|
|
|
|
if (shouldDropBlockedUserMessage(content)) {
|
|
|
|
|
window.log.info('Dropping blocked user message');
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
window.log.info(
|
|
|
|
|
'Allowing group-control message only from blocked user'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { FALLBACK_MESSAGE } = SignalService.Envelope.Type;
|
|
|
|
|
const { FALLBACK_MESSAGE } = SignalService.Envelope.Type;
|
|
|
|
|
|
|
|
|
|
await ConversationController.getOrCreateAndWait(envelope.source, 'private');
|
|
|
|
|
await ConversationController.getOrCreateAndWait(envelope.source, 'private');
|
|
|
|
|
|
|
|
|
|
if (content.preKeyBundleMessage) {
|
|
|
|
|
await handleSessionRequestMessage(envelope, content.preKeyBundleMessage);
|
|
|
|
|
} else if (envelope.type !== FALLBACK_MESSAGE) {
|
|
|
|
|
const device = new PubKey(envelope.source);
|
|
|
|
|
if (content.preKeyBundleMessage) {
|
|
|
|
|
await handleSessionRequestMessage(envelope, content.preKeyBundleMessage);
|
|
|
|
|
} else if (envelope.type !== FALLBACK_MESSAGE) {
|
|
|
|
|
const device = new PubKey(envelope.source);
|
|
|
|
|
|
|
|
|
|
await SessionProtocol.onSessionEstablished(device);
|
|
|
|
|
await libsession.getMessageQueue().processPending(device);
|
|
|
|
|
}
|
|
|
|
|
await SessionProtocol.onSessionEstablished(device);
|
|
|
|
|
await libsession.getMessageQueue().processPending(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (content.pairingAuthorisation) {
|
|
|
|
|
await handlePairingAuthorisationMessage(
|
|
|
|
|
envelope,
|
|
|
|
|
content.pairingAuthorisation,
|
|
|
|
|
content.dataMessage
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (content.pairingAuthorisation) {
|
|
|
|
|
await handlePairingAuthorisationMessage(
|
|
|
|
|
envelope,
|
|
|
|
|
content.pairingAuthorisation,
|
|
|
|
|
content.dataMessage
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (content.syncMessage) {
|
|
|
|
|
await handleSyncMessage(envelope, content.syncMessage);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (content.syncMessage) {
|
|
|
|
|
await handleSyncMessage(envelope, content.syncMessage);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (content.dataMessage) {
|
|
|
|
|
if (
|
|
|
|
|
content.dataMessage.profileKey &&
|
|
|
|
|
content.dataMessage.profileKey.length === 0
|
|
|
|
|
) {
|
|
|
|
|
content.dataMessage.profileKey = null;
|
|
|
|
|
if (content.dataMessage) {
|
|
|
|
|
if (
|
|
|
|
|
content.dataMessage.profileKey &&
|
|
|
|
|
content.dataMessage.profileKey.length === 0
|
|
|
|
|
) {
|
|
|
|
|
content.dataMessage.profileKey = null;
|
|
|
|
|
}
|
|
|
|
|
await handleDataMessage(envelope, content.dataMessage);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
await handleDataMessage(envelope, content.dataMessage);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (content.nullMessage) {
|
|
|
|
|
await handleNullMessage(envelope);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (content.callMessage) {
|
|
|
|
|
await handleCallMessage(envelope);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (content.receiptMessage) {
|
|
|
|
|
await handleReceiptMessage(envelope, content.receiptMessage);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (content.typingMessage) {
|
|
|
|
|
if (
|
|
|
|
|
content.typingMessage.groupId &&
|
|
|
|
|
content.typingMessage.groupId.length === 0
|
|
|
|
|
) {
|
|
|
|
|
content.typingMessage.groupId = null;
|
|
|
|
|
if (content.nullMessage) {
|
|
|
|
|
await handleNullMessage(envelope);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
await handleTypingMessage(envelope, content.typingMessage);
|
|
|
|
|
return;
|
|
|
|
|
if (content.callMessage) {
|
|
|
|
|
await handleCallMessage(envelope);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (content.receiptMessage) {
|
|
|
|
|
await handleReceiptMessage(envelope, content.receiptMessage);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (content.typingMessage) {
|
|
|
|
|
if (
|
|
|
|
|
content.typingMessage.groupId &&
|
|
|
|
|
content.typingMessage.groupId.length === 0
|
|
|
|
|
) {
|
|
|
|
|
content.typingMessage.groupId = null;
|
|
|
|
|
}
|
|
|
|
|
await handleTypingMessage(envelope, content.typingMessage);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
window.log.warn(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onReadReceipt(readAt: any, timestamp: any, reader: any) {
|
|
|
|
|