From 5069f48cf038710ae67d3551c440c2366c1c447a Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Thu, 5 Aug 2021 17:17:23 -0700 Subject: [PATCH] Message Send Log: Increase retention length --- ts/background.ts | 19 +++++++++++++++++-- ts/models/conversations.ts | 10 +++++----- ts/textsecure/SendMessage.ts | 4 ++-- ts/util/handleRetry.ts | 4 ++-- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ts/background.ts b/ts/background.ts index 5fe25724506e..0f3dd3e5e8ac 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -1030,9 +1030,24 @@ export async function startApp(): Promise { const now = Date.now(); const HOUR = 1000 * 60 * 60; const DAY = 24 * HOUR; - const oneDayAgo = now - DAY; + let sentProtoMaxAge = 14 * DAY; + try { - await window.Signal.Data.deleteSentProtosOlderThan(oneDayAgo); + sentProtoMaxAge = parseIntOrThrow( + window.Signal.RemoteConfig.getValue('desktop.retryRespondMaxAge'), + 'retryRespondMaxAge' + ); + } catch (error) { + window.log.warn( + 'background/setInterval: Failed to parse integer from desktop.retryRespondMaxAge feature flag', + error && error.stack ? error.stack : error + ); + } + + try { + await window.Signal.Data.deleteSentProtosOlderThan( + now - sentProtoMaxAge + ); } catch (error) { window.log.error( 'background/onready/setInterval: Error deleting sent protos: ', diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index f4b5f223b13a..f49b1443fc37 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -1203,7 +1203,10 @@ export class ConversationModel extends window.Backbone const { ContentHint } = Proto.UnidentifiedSenderMessage.Message; - const sendOptions = await getSendOptions(this.attributes); + const sendOptions = { + ...(await getSendOptions(this.attributes)), + online: true, + }; if (isDirectConversation(this.attributes)) { handleMessageSend( window.textsecure.messaging.sendMessageProtoAndWait({ @@ -1212,10 +1215,7 @@ export class ConversationModel extends window.Backbone proto: contentMessage, contentHint: ContentHint.IMPLICIT, groupId: undefined, - options: { - ...sendOptions, - online: true, - }, + options: sendOptions, }), { messageIds: [], sendType: 'typing' } ); diff --git a/ts/textsecure/SendMessage.ts b/ts/textsecure/SendMessage.ts index a4fb591e4584..6ee1e5164708 100644 --- a/ts/textsecure/SendMessage.ts +++ b/ts/textsecure/SendMessage.ts @@ -1882,12 +1882,12 @@ export default class MessageSender { const ourUuid = window.textsecure.storage.user.getUuid(); if (!ourUuid) { throw new Error( - 'sendSenderKeyDistributionMessage: Failed to fetch our UUID!' + 'getSenderKeyDistributionMessage: Failed to fetch our UUID!' ); } const ourDeviceId = parseIntOrThrow( window.textsecure.storage.user.getDeviceId(), - 'sendSenderKeyDistributionMessage' + 'getSenderKeyDistributionMessage' ); const protocolAddress = ProtocolAddress.new(ourUuid, ourDeviceId); diff --git a/ts/util/handleRetry.ts b/ts/util/handleRetry.ts index 32e16e400a46..751621193433 100644 --- a/ts/util/handleRetry.ts +++ b/ts/util/handleRetry.ts @@ -56,8 +56,8 @@ export async function onRetryRequest(event: RetryRequestEvent): Promise { } const HOUR = 60 * 60 * 1000; - const ONE_DAY = 24 * HOUR; - let retryRespondMaxAge = ONE_DAY; + const DAY = 24 * HOUR; + let retryRespondMaxAge = 14 * DAY; try { retryRespondMaxAge = parseIntOrThrow( RemoteConfig.getValue('desktop.retryRespondMaxAge'),