From aa2438ad001f5268a0ca5ba006fd897a2fd1adeb Mon Sep 17 00:00:00 2001 From: sachaaaaa Date: Fri, 30 Aug 2019 10:54:52 +1000 Subject: [PATCH] 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