ignore other empty buffers which should be null after protobuf decode

pull/1217/head
Audric Ackermann 5 years ago
parent 26e3eca1a2
commit 2257420523
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -370,7 +370,12 @@ export async function innerHandleContentMessage(
}
if (content.dataMessage) {
// Are we not supposed to await here?
if (
content.dataMessage.profileKey &&
content.dataMessage.profileKey.length === 0
) {
content.dataMessage.profileKey = null;
}
await handleDataMessage(envelope, content.dataMessage);
return;
}
@ -387,6 +392,12 @@ export async function innerHandleContentMessage(
return;
}
if (content.typingMessage) {
if (
content.typingMessage.groupId &&
content.typingMessage.groupId.length === 0
) {
content.typingMessage.groupId = null;
}
await handleTypingMessage(envelope, content.typingMessage);
return;
}

@ -83,9 +83,10 @@ function cleanAttachment(attachment: any) {
..._.omit(attachment, 'thumbnail'),
id: attachment.id.toString(),
key: attachment.key ? StringUtils.decode(attachment.key, 'base64') : null,
digest: attachment.digest
? StringUtils.decode(attachment.digest, 'base64')
: null,
digest:
attachment.digest && attachment.digest.length > 0
? StringUtils.decode(attachment.digest, 'base64')
: null,
};
}
@ -138,7 +139,7 @@ function cleanAttachments(decrypted: any) {
quote.attachments = (quote.attachments || []).map((item: any) => {
const { thumbnail } = item;
if (!thumbnail) {
if (!thumbnail || thumbnail.length === 0) {
return item;
}

@ -215,6 +215,10 @@ function parseContacts(arrbuf: ArrayBuffer): Array<any> {
new Uint8Array(nextBuffer)
);
if (proto.profileKey && proto.profileKey.length === 0) {
proto.profileKey = null;
}
buffer.skip(len);
if (proto.avatar) {
@ -259,7 +263,7 @@ export async function handleContacts(
window.log.info('contact sync');
// const { blob } = contacts;
if (!contacts.data) {
if (!contacts.data || contacts.data.length === 0) {
window.log.error('Contacts without data');
return;
}

@ -48,7 +48,6 @@ interface ReqOptions {
const incomingMessagePromises: Array<Promise<any>> = [];
async function handleEnvelope(envelope: EnvelopePlus) {
const { textsecure } = window;
// TODO: enable below
// if (this.stoppingProcessing) {
@ -59,7 +58,7 @@ async function handleEnvelope(envelope: EnvelopePlus) {
return onDeliveryReceipt(envelope.source, envelope.timestamp);
}
if (envelope.content) {
if (envelope.content && envelope.content.length > 0) {
return handleContentMessage(envelope);
}

Loading…
Cancel
Save