Shorter TTL for pairing requests

This commit is contained in:
sachaaaaa 2019-08-30 10:54:52 +10:00
parent 1d4c98adf0
commit aa2438ad00
2 changed files with 15 additions and 11 deletions

View file

@ -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

View file

@ -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