diff --git a/ts/session/constants.ts b/ts/session/constants.ts index 7f8b82be3..314e5b174 100644 --- a/ts/session/constants.ts +++ b/ts/session/constants.ts @@ -3,9 +3,7 @@ import { DAYS, SECONDS } from './utils/Number'; export const TTL_DEFAULT = { TYPING_MESSAGE: 20 * SECONDS, - REGULAR_MESSAGE: 2 * DAYS, - ENCRYPTION_PAIR_GROUP: 4 * DAYS, - CONFIGURATION_MESSAGE: 4 * DAYS, + TTL_MAX: 14 * DAYS, }; export const PROTOCOLS = { diff --git a/ts/session/messages/outgoing/ContentMessage.ts b/ts/session/messages/outgoing/ContentMessage.ts index 7eba3d364..4dab60ab4 100644 --- a/ts/session/messages/outgoing/ContentMessage.ts +++ b/ts/session/messages/outgoing/ContentMessage.ts @@ -1,11 +1,14 @@ import { Message } from '.'; import { SignalService } from '../../../protobuf'; +import { TTL_DEFAULT } from '../../constants'; export abstract class ContentMessage extends Message { public plainTextBuffer(): Uint8Array { return SignalService.Content.encode(this.contentProto()).finish(); } - public abstract ttl(): number; + public ttl(): number { + return TTL_DEFAULT.TTL_MAX; + } public abstract contentProto(): SignalService.Content; } diff --git a/ts/session/messages/outgoing/DataMessage.ts b/ts/session/messages/outgoing/DataMessage.ts index 8d9cb115c..4852eee1a 100644 --- a/ts/session/messages/outgoing/DataMessage.ts +++ b/ts/session/messages/outgoing/DataMessage.ts @@ -10,8 +10,4 @@ export abstract class DataMessage extends ContentMessage { dataMessage: this.dataProto(), }); } - - public ttl(): number { - return TTL_DEFAULT.REGULAR_MESSAGE; - } } diff --git a/ts/session/messages/outgoing/controlMessage/ConfigurationMessage.ts b/ts/session/messages/outgoing/controlMessage/ConfigurationMessage.ts index 4c4db54eb..9d6106792 100644 --- a/ts/session/messages/outgoing/controlMessage/ConfigurationMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/ConfigurationMessage.ts @@ -59,10 +59,6 @@ export class ConfigurationMessage extends ContentMessage { } } - public ttl(): number { - return Constants.TTL_DEFAULT.CONFIGURATION_MESSAGE; - } - public contentProto(): SignalService.Content { return new SignalService.Content({ configurationMessage: this.configurationProto(), diff --git a/ts/session/messages/outgoing/controlMessage/ExpirationTimerUpdateMessage.ts b/ts/session/messages/outgoing/controlMessage/ExpirationTimerUpdateMessage.ts index c2c989ea8..46af11f57 100644 --- a/ts/session/messages/outgoing/controlMessage/ExpirationTimerUpdateMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/ExpirationTimerUpdateMessage.ts @@ -25,10 +25,6 @@ export class ExpirationTimerUpdateMessage extends DataMessage { this.syncTarget = syncTarget ? PubKey.cast(syncTarget).key : undefined; } - public ttl(): number { - return Constants.TTL_DEFAULT.REGULAR_MESSAGE; - } - public dataProto(): SignalService.DataMessage { const data = new SignalService.DataMessage(); diff --git a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupAddedMembersMessage.ts b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupAddedMembersMessage.ts index 25ac6f5d2..003e9a0fb 100644 --- a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupAddedMembersMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupAddedMembersMessage.ts @@ -34,8 +34,4 @@ export class ClosedGroupAddedMembersMessage extends ClosedGroupMessage { return dataMessage; } - - public ttl(): number { - return Constants.TTL_DEFAULT.REGULAR_MESSAGE; - } } diff --git a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairMessage.ts b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairMessage.ts index 4942b5d61..008218cf4 100644 --- a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairMessage.ts @@ -40,8 +40,4 @@ export class ClosedGroupEncryptionPairMessage extends ClosedGroupMessage { return dataMessage; } - - public ttl(): number { - return Constants.TTL_DEFAULT.ENCRYPTION_PAIR_GROUP; - } } diff --git a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairRequestMessage.ts b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairRequestMessage.ts index 057986f05..f634d5398 100644 --- a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairRequestMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupEncryptionPairRequestMessage.ts @@ -13,8 +13,4 @@ export class ClosedGroupEncryptionPairRequestMessage extends ClosedGroupMessage return dataMessage; } - - public ttl(): number { - return Constants.TTL_DEFAULT.ENCRYPTION_PAIR_GROUP; - } } diff --git a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupMemberLeftMessage.ts b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupMemberLeftMessage.ts index 5aa7695a6..1760e5153 100644 --- a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupMemberLeftMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupMemberLeftMessage.ts @@ -12,8 +12,4 @@ export class ClosedGroupMemberLeftMessage extends ClosedGroupMessage { return dataMessage; } - - public ttl(): number { - return Constants.TTL_DEFAULT.REGULAR_MESSAGE; - } } diff --git a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupNameChangeMessage.ts b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupNameChangeMessage.ts index d5de53624..278e8392f 100644 --- a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupNameChangeMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupNameChangeMessage.ts @@ -32,8 +32,4 @@ export class ClosedGroupNameChangeMessage extends ClosedGroupMessage { return dataMessage; } - - public ttl(): number { - return Constants.TTL_DEFAULT.REGULAR_MESSAGE; - } } diff --git a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupRemovedMembersMessage.ts b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupRemovedMembersMessage.ts index 0087d4fab..b06e2ae56 100644 --- a/ts/session/messages/outgoing/controlMessage/group/ClosedGroupRemovedMembersMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/group/ClosedGroupRemovedMembersMessage.ts @@ -33,8 +33,4 @@ export class ClosedGroupRemovedMembersMessage extends ClosedGroupMessage { return dataMessage; } - - public ttl(): number { - return Constants.TTL_DEFAULT.REGULAR_MESSAGE; - } } diff --git a/ts/session/messages/outgoing/controlMessage/receipt/ReceiptMessage.ts b/ts/session/messages/outgoing/controlMessage/receipt/ReceiptMessage.ts index c93415e1b..b8d5170ea 100644 --- a/ts/session/messages/outgoing/controlMessage/receipt/ReceiptMessage.ts +++ b/ts/session/messages/outgoing/controlMessage/receipt/ReceiptMessage.ts @@ -14,10 +14,6 @@ export abstract class ReceiptMessage extends ContentMessage { this.timestamps = timestamps; } - public ttl(): number { - return Constants.TTL_DEFAULT.REGULAR_MESSAGE; - } - public abstract getReceiptType(): SignalService.ReceiptMessage.Type; public contentProto(): SignalService.Content { diff --git a/ts/session/messages/outgoing/visibleMessage/ClosedGroupVisibleMessage.ts b/ts/session/messages/outgoing/visibleMessage/ClosedGroupVisibleMessage.ts index 0c6eff1ba..df56e73da 100644 --- a/ts/session/messages/outgoing/visibleMessage/ClosedGroupVisibleMessage.ts +++ b/ts/session/messages/outgoing/visibleMessage/ClosedGroupVisibleMessage.ts @@ -23,11 +23,6 @@ export class ClosedGroupVisibleMessage extends ClosedGroupMessage { }); this.chatMessage = params.chatMessage; } - - public ttl(): number { - return Constants.TTL_DEFAULT.REGULAR_MESSAGE; - } - public dataProto(): SignalService.DataMessage { const dataProto = this.chatMessage.dataProto(); diff --git a/ts/session/messages/outgoing/visibleMessage/GroupInvitationMessage.ts b/ts/session/messages/outgoing/visibleMessage/GroupInvitationMessage.ts index b4769c2ce..48685ac12 100644 --- a/ts/session/messages/outgoing/visibleMessage/GroupInvitationMessage.ts +++ b/ts/session/messages/outgoing/visibleMessage/GroupInvitationMessage.ts @@ -26,10 +26,6 @@ export class GroupInvitationMessage extends DataMessage { this.expireTimer = params.expireTimer; } - public ttl(): number { - return Constants.TTL_DEFAULT.REGULAR_MESSAGE; - } - public dataProto(): SignalService.DataMessage { const groupInvitation = new SignalService.DataMessage.GroupInvitation({ serverAddress: this.serverAddress, diff --git a/ts/session/messages/outgoing/visibleMessage/VisibleMessage.ts b/ts/session/messages/outgoing/visibleMessage/VisibleMessage.ts index bb962bbb9..e77a0e069 100644 --- a/ts/session/messages/outgoing/visibleMessage/VisibleMessage.ts +++ b/ts/session/messages/outgoing/visibleMessage/VisibleMessage.ts @@ -92,10 +92,6 @@ export class VisibleMessage extends DataMessage { this.syncTarget = params.syncTarget; } - public ttl(): number { - return Constants.TTL_DEFAULT.REGULAR_MESSAGE; - } - public dataProto(): SignalService.DataMessage { const dataMessage = new SignalService.DataMessage(); diff --git a/ts/test/session/unit/messages/ChatMessage_test.ts b/ts/test/session/unit/messages/ChatMessage_test.ts index 8896bb215..bd99449fa 100644 --- a/ts/test/session/unit/messages/ChatMessage_test.ts +++ b/ts/test/session/unit/messages/ChatMessage_test.ts @@ -130,7 +130,7 @@ describe('VisibleMessage', () => { const message = new VisibleMessage({ timestamp: Date.now(), }); - expect(message.ttl()).to.equal(Constants.TTL_DEFAULT.REGULAR_MESSAGE); + expect(message.ttl()).to.equal(Constants.TTL_DEFAULT.TTL_MAX); }); it('has an identifier', () => { diff --git a/ts/test/session/unit/messages/ClosedGroupChatMessage_test.ts b/ts/test/session/unit/messages/ClosedGroupChatMessage_test.ts index c17d76f96..a244c6674 100644 --- a/ts/test/session/unit/messages/ClosedGroupChatMessage_test.ts +++ b/ts/test/session/unit/messages/ClosedGroupChatMessage_test.ts @@ -50,7 +50,7 @@ describe('ClosedGroupVisibleMessage', () => { groupId, chatMessage, }); - expect(message.ttl()).to.equal(Constants.TTL_DEFAULT.REGULAR_MESSAGE); + expect(message.ttl()).to.equal(Constants.TTL_DEFAULT.TTL_MAX); }); it('has an identifier', () => { diff --git a/ts/test/session/unit/messages/ConfigurationMessage_test.ts b/ts/test/session/unit/messages/ConfigurationMessage_test.ts index 0fb597084..008ef7b3f 100644 --- a/ts/test/session/unit/messages/ConfigurationMessage_test.ts +++ b/ts/test/session/unit/messages/ConfigurationMessage_test.ts @@ -1,5 +1,6 @@ import { expect } from 'chai'; import { ECKeyPair } from '../../../../receiver/keypairs'; +import { TTL_DEFAULT } from '../../../../session/constants'; import { ConfigurationMessage, @@ -65,7 +66,7 @@ describe('ConfigurationMessage', () => { contacts: [], }; const configMessage = new ConfigurationMessage(params); - expect(configMessage.ttl()).to.be.equal(4 * 24 * 60 * 60 * 1000); + expect(configMessage.ttl()).to.be.equal(TTL_DEFAULT.TTL_MAX); }); describe('ConfigurationMessageClosedGroup', () => { diff --git a/ts/test/session/unit/messages/GroupInvitationMessage_test.ts b/ts/test/session/unit/messages/GroupInvitationMessage_test.ts index 635446195..e50f94841 100644 --- a/ts/test/session/unit/messages/GroupInvitationMessage_test.ts +++ b/ts/test/session/unit/messages/GroupInvitationMessage_test.ts @@ -31,7 +31,7 @@ describe('GroupInvitationMessage', () => { }); it('correct ttl', () => { - expect(message.ttl()).to.equal(Constants.TTL_DEFAULT.REGULAR_MESSAGE); + expect(message.ttl()).to.equal(Constants.TTL_DEFAULT.TTL_MAX); }); it('has an identifier', () => { diff --git a/ts/test/session/unit/messages/ReceiptMessage_test.ts b/ts/test/session/unit/messages/ReceiptMessage_test.ts index c13509427..94af6e3b7 100644 --- a/ts/test/session/unit/messages/ReceiptMessage_test.ts +++ b/ts/test/session/unit/messages/ReceiptMessage_test.ts @@ -38,8 +38,8 @@ describe('ReceiptMessage', () => { }); it('correct ttl', () => { - expect(readMessage.ttl()).to.equal(Constants.TTL_DEFAULT.REGULAR_MESSAGE); - expect(deliveryMessage.ttl()).to.equal(Constants.TTL_DEFAULT.REGULAR_MESSAGE); + expect(readMessage.ttl()).to.equal(Constants.TTL_DEFAULT.TTL_MAX); + expect(deliveryMessage.ttl()).to.equal(Constants.TTL_DEFAULT.TTL_MAX); }); it('has an identifier', () => {