From aa2438ad001f5268a0ca5ba006fd897a2fd1adeb Mon Sep 17 00:00:00 2001 From: sachaaaaa Date: Fri, 30 Aug 2019 10:54:52 +1000 Subject: [PATCH 1/2] Shorter TTL for pairing requests --- libloki/api.js | 2 +- libtextsecure/outgoing_message.js | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/libloki/api.js b/libloki/api.js index a07c37859..b5ba22d98 100644 --- a/libloki/api.js +++ b/libloki/api.js @@ -106,7 +106,7 @@ const content = new textsecure.protobuf.Content({ pairingAuthorisation, }); - const options = {}; + const options = { messageType: 'pairing-request' }; const p = new Promise((resolve, reject) => { const outgoingMessage = new textsecure.OutgoingMessage( null, // server diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index ea9e0446a..701b94419 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -370,17 +370,21 @@ OutgoingMessage.prototype = { dcodeIO.ByteBuffer.wrap(ciphertext.body, 'binary').toArrayBuffer() ); } - let ttl; - if (this.messageType === 'friend-request') { - ttl = 4 * 24 * 60 * 60 * 1000; // 4 days for friend request message - } else if (this.messageType === 'onlineBroadcast') { - ttl = 60 * 1000; // 1 minute for online broadcast message - } else if (this.messageType === 'typing') { - ttl = 60 * 1000; // 1 minute for typing indicators - } else { - const hours = window.getMessageTTL() || 24; // 1 day default for any other message - ttl = hours * 60 * 60 * 1000; + const getTTL = (type) => { + switch (type) { + case 'friend-request': + return 4 * 24 * 60 * 60 * 1000; // 4 days for friend request message + case 'onlineBroadcast': + return 60 * 1000; // 1 minute for online broadcast message + case 'typing': + return 60 * 1000; // 1 minute for typing indicators + case 'pairing-request': + return 2 * 60 * 1000; // 2 minutes for pairing requests + default: + return (window.getMessageTTL() || 24) * 60 * 60 * 1000; // 1 day default for any other message + } } + const ttl = getTTL(this.messageType); return { type: ciphertext.type, // FallBackSessionCipher sets this to FRIEND_REQUEST From 7b9e578d8a0df555141f27c0d24ed9fbe67a3745 Mon Sep 17 00:00:00 2001 From: sachaaaaa Date: Fri, 30 Aug 2019 11:33:56 +1000 Subject: [PATCH 2/2] lint --- js/views/standalone_registration_view.js | 4 +++- libtextsecure/outgoing_message.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/js/views/standalone_registration_view.js b/js/views/standalone_registration_view.js index ef64c4be7..423123a57 100644 --- a/js/views/standalone_registration_view.js +++ b/js/views/standalone_registration_view.js @@ -55,7 +55,9 @@ this.onValidatePassword(); - this.onSecondaryDeviceRegistered = this.onSecondaryDeviceRegistered.bind(this); + this.onSecondaryDeviceRegistered = this.onSecondaryDeviceRegistered.bind( + this + ); }, events: { 'validation input.number': 'onValidation', diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index 701b94419..a1feea2ae 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -370,7 +370,7 @@ OutgoingMessage.prototype = { dcodeIO.ByteBuffer.wrap(ciphertext.body, 'binary').toArrayBuffer() ); } - const getTTL = (type) => { + const getTTL = type => { switch (type) { case 'friend-request': return 4 * 24 * 60 * 60 * 1000; // 4 days for friend request message @@ -383,7 +383,7 @@ OutgoingMessage.prototype = { default: return (window.getMessageTTL() || 24) * 60 * 60 * 1000; // 1 day default for any other message } - } + }; const ttl = getTTL(this.messageType); return {