mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Shorter TTL for pairing requests
This commit is contained in:
parent
1d4c98adf0
commit
aa2438ad00
2 changed files with 15 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue