Move logic into handleDataMessage for proper queuing
This commit is contained in:
parent
afddc852cc
commit
7ca0dfdfbe
5 changed files with 116 additions and 128 deletions
|
@ -1239,19 +1239,17 @@ MessageReceiver.prototype.extend({
|
|||
// Note that messages may (generally) only perform one action and we ignore remaining
|
||||
// fields after the first action.
|
||||
|
||||
if (window.TIMESTAMP_VALIDATION) {
|
||||
if (!envelope.timestamp || !decrypted.timestamp) {
|
||||
throw new Error('Missing timestamp on dataMessage or envelope');
|
||||
}
|
||||
if (!envelope.timestamp || !decrypted.timestamp) {
|
||||
throw new Error('Missing timestamp on dataMessage or envelope');
|
||||
}
|
||||
|
||||
const envelopeTimestamp = envelope.timestamp.toNumber();
|
||||
const decryptedTimestamp = decrypted.timestamp.toNumber();
|
||||
const envelopeTimestamp = envelope.timestamp.toNumber();
|
||||
const decryptedTimestamp = decrypted.timestamp.toNumber();
|
||||
|
||||
if (envelopeTimestamp !== decryptedTimestamp) {
|
||||
throw new Error(
|
||||
`Timestamp ${decrypted.timestamp} in DataMessage did not match envelope timestamp ${envelope.timestamp}`
|
||||
);
|
||||
}
|
||||
if (envelopeTimestamp !== decryptedTimestamp) {
|
||||
throw new Error(
|
||||
`Timestamp ${decrypted.timestamp} in DataMessage did not match envelope timestamp ${envelope.timestamp}`
|
||||
);
|
||||
}
|
||||
|
||||
if (decrypted.flags == null) {
|
||||
|
|
|
@ -188,11 +188,7 @@ MessageSender.prototype = {
|
|||
);
|
||||
},
|
||||
|
||||
getPaddedAttachment(data, shouldPad) {
|
||||
if (!window.PAD_ALL_ATTACHMENTS && !shouldPad) {
|
||||
return data;
|
||||
}
|
||||
|
||||
getPaddedAttachment(data) {
|
||||
const size = data.byteLength;
|
||||
const paddedSize = this._getAttachmentSizeBucket(size);
|
||||
const padding = window.Signal.Crypto.getZeroes(paddedSize - size);
|
||||
|
@ -200,7 +196,7 @@ MessageSender.prototype = {
|
|||
return window.Signal.Crypto.concatenateBytes(data, padding);
|
||||
},
|
||||
|
||||
async makeAttachmentPointer(attachment, shouldPad = false) {
|
||||
async makeAttachmentPointer(attachment) {
|
||||
if (typeof attachment !== 'object' || attachment == null) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
@ -217,7 +213,7 @@ MessageSender.prototype = {
|
|||
);
|
||||
}
|
||||
|
||||
const padded = this.getPaddedAttachment(data, shouldPad);
|
||||
const padded = this.getPaddedAttachment(data);
|
||||
const key = libsignal.crypto.getRandomBytes(64);
|
||||
const iv = libsignal.crypto.getRandomBytes(16);
|
||||
|
||||
|
@ -308,14 +304,10 @@ MessageSender.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
const shouldPad = true;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
message.sticker = {
|
||||
...sticker,
|
||||
attachmentPointer: await this.makeAttachmentPointer(
|
||||
sticker.data,
|
||||
shouldPad
|
||||
),
|
||||
attachmentPointer: await this.makeAttachmentPointer(sticker.data),
|
||||
};
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.name === 'HTTPError') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue