Refactor 'waiting' flags into one location, fix timestamp check
This commit is contained in:
parent
fd36720079
commit
e18b6bed1f
6 changed files with 39 additions and 13 deletions
|
@ -866,6 +866,10 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
async sendStickerMessage(packId, stickerId) {
|
async sendStickerMessage(packId, stickerId) {
|
||||||
|
if (!window.ENABLE_STICKER_SEND) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const packData = window.Signal.Stickers.getStickerPack(packId);
|
const packData = window.Signal.Stickers.getStickerPack(packId);
|
||||||
const stickerData = window.Signal.Stickers.getSticker(packId, stickerId);
|
const stickerData = window.Signal.Stickers.getSticker(packId, stickerId);
|
||||||
if (!stickerData || !packData) {
|
if (!stickerData || !packData) {
|
||||||
|
|
|
@ -1061,7 +1061,6 @@
|
||||||
quote: quoteWithData,
|
quote: quoteWithData,
|
||||||
preview: previewWithData,
|
preview: previewWithData,
|
||||||
sticker: stickerWithData,
|
sticker: stickerWithData,
|
||||||
needsSync: !this.get('synced'),
|
|
||||||
expireTimer: this.get('expireTimer'),
|
expireTimer: this.get('expireTimer'),
|
||||||
profileKey,
|
profileKey,
|
||||||
group: {
|
group: {
|
||||||
|
@ -1165,8 +1164,12 @@
|
||||||
|
|
||||||
// This is used by sendSyncMessage, then set to null
|
// This is used by sendSyncMessage, then set to null
|
||||||
if (result.dataMessage) {
|
if (result.dataMessage) {
|
||||||
|
// When we're not sending recipient updates, we won't save the dataMessage
|
||||||
|
// unless it's the first time we attempt to send the message.
|
||||||
|
if (!this.get('synced') || window.SEND_RECIPIENT_UPDATES) {
|
||||||
this.set({ dataMessage: result.dataMessage });
|
this.set({ dataMessage: result.dataMessage });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const sentTo = this.get('sent_to') || [];
|
const sentTo = this.get('sent_to') || [];
|
||||||
this.set({
|
this.set({
|
||||||
|
@ -1301,7 +1304,7 @@
|
||||||
const isUpdate = Boolean(this.get('synced'));
|
const isUpdate = Boolean(this.get('synced'));
|
||||||
|
|
||||||
// Until isRecipientUpdate sync messages are widely supported, will not send them
|
// Until isRecipientUpdate sync messages are widely supported, will not send them
|
||||||
if (isUpdate) {
|
if (isUpdate && !window.SEND_RECIPIENT_UPDATES) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -315,6 +315,10 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
setupStickerPickerButton() {
|
setupStickerPickerButton() {
|
||||||
|
if (!window.ENABLE_STICKER_SEND) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
onClickAddPack: () => this.showStickerManager(),
|
onClickAddPack: () => this.showStickerManager(),
|
||||||
onPickSticker: (packId, stickerId) =>
|
onPickSticker: (packId, stickerId) =>
|
||||||
|
@ -1318,6 +1322,10 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
showStickerPackPreview(packId) {
|
showStickerPackPreview(packId) {
|
||||||
|
if (!window.ENABLE_STICKER_SEND) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
packId,
|
packId,
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
|
|
|
@ -1304,14 +1304,20 @@ MessageReceiver.prototype.extend({
|
||||||
// Note that messages may (generally) only perform one action and we ignore remaining
|
// Note that messages may (generally) only perform one action and we ignore remaining
|
||||||
// fields after the first action.
|
// fields after the first action.
|
||||||
|
|
||||||
const TIMESTAMP_VALIDATION = false;
|
if (window.TIMESTAMP_VALIDATION) {
|
||||||
if (TIMESTAMP_VALIDATION && envelope.timestamp !== decrypted.timestamp) {
|
const envelopeTimestamp = envelope.timestamp.toNumber();
|
||||||
|
const decryptedTimestamp = decrypted.timestamp.toNumber();
|
||||||
|
|
||||||
|
if (envelopeTimestamp !== decryptedTimestamp) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Timestamp ${
|
`Timestamp ${
|
||||||
decrypted.timestamp
|
decrypted.timestamp
|
||||||
} in DataMessage did not match envelope timestamp ${envelope.timestamp}`
|
} in DataMessage did not match envelope timestamp ${
|
||||||
|
envelope.timestamp
|
||||||
|
}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (decrypted.flags == null) {
|
if (decrypted.flags == null) {
|
||||||
decrypted.flags = 0;
|
decrypted.flags = 0;
|
||||||
|
|
|
@ -185,7 +185,7 @@ MessageSender.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getPaddedAttachment(data, shouldPad) {
|
getPaddedAttachment(data, shouldPad) {
|
||||||
if (!shouldPad) {
|
if (!window.PAD_ALL_ATTACHMENTS && !shouldPad) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
/* global Whisper: false */
|
/* global Whisper, window */
|
||||||
/* global window: false */
|
|
||||||
|
|
||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
|
@ -9,6 +8,12 @@ const { deferredToPromise } = require('./js/modules/deferred_to_promise');
|
||||||
const { app } = electron.remote;
|
const { app } = electron.remote;
|
||||||
const { systemPreferences } = electron.remote.require('electron');
|
const { systemPreferences } = electron.remote.require('electron');
|
||||||
|
|
||||||
|
// Waiting for clients to implement changes on receive side
|
||||||
|
window.ENABLE_STICKER_SEND = false;
|
||||||
|
window.TIMESTAMP_VALIDATION = false;
|
||||||
|
window.PAD_ALL_ATTACHMENTS = false;
|
||||||
|
window.SEND_RECIPIENT_UPDATES = false;
|
||||||
|
|
||||||
window.PROTO_ROOT = 'protos';
|
window.PROTO_ROOT = 'protos';
|
||||||
const config = require('url').parse(window.location.toString(), true).query;
|
const config = require('url').parse(window.location.toString(), true).query;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue