Shorter TTL for pairing requests

pull/454/head
sachaaaaa 6 years ago
parent 1d4c98adf0
commit aa2438ad00

@ -106,7 +106,7 @@
const content = new textsecure.protobuf.Content({ const content = new textsecure.protobuf.Content({
pairingAuthorisation, pairingAuthorisation,
}); });
const options = {}; const options = { messageType: 'pairing-request' };
const p = new Promise((resolve, reject) => { const p = new Promise((resolve, reject) => {
const outgoingMessage = new textsecure.OutgoingMessage( const outgoingMessage = new textsecure.OutgoingMessage(
null, // server null, // server

@ -370,17 +370,21 @@ OutgoingMessage.prototype = {
dcodeIO.ByteBuffer.wrap(ciphertext.body, 'binary').toArrayBuffer() dcodeIO.ByteBuffer.wrap(ciphertext.body, 'binary').toArrayBuffer()
); );
} }
let ttl; const getTTL = (type) => {
if (this.messageType === 'friend-request') { switch (type) {
ttl = 4 * 24 * 60 * 60 * 1000; // 4 days for friend request message case 'friend-request':
} else if (this.messageType === 'onlineBroadcast') { return 4 * 24 * 60 * 60 * 1000; // 4 days for friend request message
ttl = 60 * 1000; // 1 minute for online broadcast message case 'onlineBroadcast':
} else if (this.messageType === 'typing') { return 60 * 1000; // 1 minute for online broadcast message
ttl = 60 * 1000; // 1 minute for typing indicators case 'typing':
} else { return 60 * 1000; // 1 minute for typing indicators
const hours = window.getMessageTTL() || 24; // 1 day default for any other message case 'pairing-request':
ttl = hours * 60 * 60 * 1000; 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 { return {
type: ciphertext.type, // FallBackSessionCipher sets this to FRIEND_REQUEST type: ciphertext.type, // FallBackSessionCipher sets this to FRIEND_REQUEST

Loading…
Cancel
Save