diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index ceae7c4ed..dbb2934a8 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -852,9 +852,9 @@ export class ConversationModel extends Backbone.Model { lastDisappearingMessageChangeTimestamp && this.getLastDisappearingMessageChangeTimestamp() >= lastDisappearingMessageChangeTimestamp ) { - window.log.info( - 'WIP: updateExpireTimer() This is an outdated disappearing message setting', - `fromSync: ${fromSync}` + window.log.debug( + '[updateExpireTimer] This is an outdated disappearing message setting', + `fromSync: ${fromSync}${existingMessage ? ` messageId: ${existingMessage.get('id')}` : ''}` ); return false; } @@ -863,10 +863,12 @@ export class ConversationModel extends Backbone.Model { isEqual(expirationMode, this.getExpirationMode()) && isEqual(expireTimer, this.getExpireTimer()) ) { - window.log.info( - `WIP: conversation: updateExpireTimer() Ignoring ExpireTimerUpdate ${ + window.log.debug( + `[updateExpireTimer] Ignoring ExpireTimerUpdate ${ fromSync ? 'config/sync ' : '' - }message as we already have the same one set.` + }message as we already have the same one set.${ + existingMessage ? ` messageId: ${existingMessage.get('id')}` : '' + }` ); return false; } @@ -883,17 +885,6 @@ export class ConversationModel extends Backbone.Model { lastDisappearingMessageChangeTimestamp, }); - window?.log?.debug( - 'WIP: updateExpireTimer() Updating conversation disappearing messages setting', - { - id: this.idForLogging(), - expirationMode, - expireTimer, - lastDisappearingMessageChangeTimestamp, - source, - } - ); - let message: MessageModel | undefined = existingMessage || undefined; const expirationType = changeToDisappearingMessageType(this, expireTimer, expirationMode); @@ -940,7 +931,7 @@ export class ConversationModel extends Backbone.Model { // if change was made remotely, don't send it to the contact/group if (receivedAt || fromSync) { window.log.debug( - `WIP: updateExpireTimer() We dont send an ExpireTimerUpdate because this was a remote change receivedAt: ${receivedAt} fromSync: ${fromSync}` + `[updateExpireTimer] We dont send an ExpireTimerUpdate because this was a remote change receivedAt: ${receivedAt} fromSync: ${fromSync} for ${this.id}` ); if (!message.getExpirationStartTimestamp()) { const canBeDeleteAfterSend = this.isMe() || this.isGroup(); @@ -952,7 +943,8 @@ export class ConversationModel extends Backbone.Model { expirationStartTimestamp: setExpirationStartTimestamp( expirationMode, message.get('sent_at'), - 'updateExpireTimer() remote change' + 'updateExpireTimer() remote change', + message.get('id') ), }); if (shouldCommitMessage) { diff --git a/ts/models/message.ts b/ts/models/message.ts index 74d912247..2d1c400af 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -1124,7 +1124,8 @@ export class MessageModel extends Backbone.Model { expirationStartTimestamp: setExpirationStartTimestamp( expirationMode, readAt, - 'markMessageReadNoCommit' + 'markMessageReadNoCommit', + this.get('id') ), }); } diff --git a/ts/receiver/configMessage.ts b/ts/receiver/configMessage.ts index 272d14f4a..735fee387 100644 --- a/ts/receiver/configMessage.ts +++ b/ts/receiver/configMessage.ts @@ -246,19 +246,6 @@ async function handleUserProfileUpdate(result: IncomingConfResult): Promise 0 - ? ReleasedFeatures.isDisappearMessageV2FeatureReleasedCached() - ? 'deleteAfterSend' - : 'legacy' - : 'off' - } wrapperNoteToSelfExpirySeconds: ${wrapperNoteToSelfExpirySeconds}` - ); - } } // make sure to write the changes to the database now as the `AvatarDownloadJob` triggered by updateOurProfileLegacyOrViaLibSession might take some time before getting run @@ -405,11 +392,6 @@ async function handleContactsUpdate(result: IncomingConfResult): Promise 0 - ? ReleasedFeatures.isDisappearMessageV2FeatureReleasedCached() - ? 'deleteAfterSend' - : 'legacy' - : 'off' - } wrapperNoteToSelfExpirySeconds: ${fromWrapper.disappearingTimerSeconds}` - ); - } } const existingTimestampMs = legacyGroupConvo.get('lastJoinedTimestamp'); @@ -751,35 +720,23 @@ async function applyConvoVolatileUpdateFromWrapper( ) .map(m => m.get('messageHash')) ); - window.log.debug( - `WIP: [applyConvoVolatileUpdateFromWrapper]\nmessages2Expire: ${JSON.stringify( - messages2Expire - )}` - ); const currentExpiryTimestamps = await getExpiriesFromSnode({ messageHashes, timestamp: lastReadMessageTimestamp, }); - window.log.debug( - `WIP: [applyConvoVolatileUpdateFromWrapper] currentExpiryTimestamps: ${JSON.stringify( - currentExpiryTimestamps - )} ` - ); - if (currentExpiryTimestamps.length) { for (let index = 0; index < messages2Expire.length; index++) { if (currentExpiryTimestamps[index] === -1) { window.log.debug( - `WIP: [applyConvoVolatileUpdateFromWrapper] invalid expiry value returned from snode. We will keep the local value.\nmessageHash: ${messageHashes[index]},` + `[applyConvoVolatileUpdateFromWrapper] invalid expiry value returned from snode. We will keep the local value of ${messages2Expire + .get(index) + .get('id')}.\nmessageHash: ${messageHashes[index]},` ); continue; } messages2Expire.at(index).set('expires_at', currentExpiryTimestamps[index]); } - window.log.debug( - `WIP: [applyConvoVolatileUpdateFromWrapper] disappear after read messages updated!` - ); } } } diff --git a/ts/receiver/contentMessage.ts b/ts/receiver/contentMessage.ts index d5b033e26..0507867d6 100644 --- a/ts/receiver/contentMessage.ts +++ b/ts/receiver/contentMessage.ts @@ -480,16 +480,7 @@ export async function innerHandleSwarmContentMessage( conversationModelForUIUpdate ); - // window.log.debug( - // `WIP:innerHandleSwarmContentMessage: ${ - // content.dataMessage.syncTarget ? 'This is a sync message.\n' : '' - // } content: ${JSON.stringify(content)} ${ - // expireUpdate ? `\n\nexpireUpdate: ${JSON.stringify(expireUpdate)}` : '' - // }` - // ); - if (expireUpdate?.isOutdated) { - window.log.debug(`WIP: ExpireUpdate is outdated. Ignoring it and removing from cache.`); await removeFromCache(envelope); return; } @@ -502,11 +493,6 @@ export async function innerHandleSwarmContentMessage( expireUpdate ); if (expireUpdate.isLegacyConversationSettingMessage) { - window.log.debug( - `WIP: The legacy message is an expiration timer update. Ignoring it.\ncontent:${JSON.stringify( - content - )}\n\nexpireUpdate: ${JSON.stringify(expireUpdate)}` - ); await removeFromCache(envelope); return; } diff --git a/ts/receiver/dataMessage.ts b/ts/receiver/dataMessage.ts index 7bbf2c5eb..9fc870509 100644 --- a/ts/receiver/dataMessage.ts +++ b/ts/receiver/dataMessage.ts @@ -3,7 +3,6 @@ import { isEmpty, isFinite, noop, omit, toNumber } from 'lodash'; import { SignalService } from '../protobuf'; import { removeFromCache } from './cache'; -import { getEnvelopeId } from './common'; import { EnvelopePlus } from './types'; import { Data } from '../data/data'; @@ -233,11 +232,6 @@ export async function handleSwarmDataMessage( } if (!messageHasVisibleContent(cleanDataMessage)) { - window?.log?.debug( - `WIP: Message ${getEnvelopeId(envelope)} ignored; it was empty`, - cleanDataMessage - ); - await removeFromCache(envelope); return; } diff --git a/ts/receiver/queuedJob.ts b/ts/receiver/queuedJob.ts index 8fccad01f..4d06b9434 100644 --- a/ts/receiver/queuedJob.ts +++ b/ts/receiver/queuedJob.ts @@ -358,7 +358,8 @@ async function markConvoAsReadIfOutgoingMessage( expirationStartTimestamp: setExpirationStartTimestamp( expirationMode, message.get('sent_at'), - 'markConvoAsReadIfOutgoingMessage' + 'markConvoAsReadIfOutgoingMessage', + message.get('id') ), }); await message.commit(); @@ -412,7 +413,8 @@ export async function handleMessageJob( expirationStartTimestamp: setExpirationStartTimestamp( expirationMode, messageModel.get('sent_at'), - 'handleMessageJob' + 'handleMessageJob', + messageModel.get('id') ), }); } @@ -426,9 +428,9 @@ export async function handleMessageJob( (!expirationTimerUpdate || isEmpty(expirationTimerUpdate)) ) { window.log.debug( - `WIP: There is a problem with the expiration timer update.\nmessage model: ${JSON.stringify( - messageModel - )}\n\nexpirationTimerUpdate: ${JSON.stringify(expirationTimerUpdate)}` + `[handleMessageJob] The ExpirationTimerUpdate is not defined correctly message: ${messageModel.get( + 'id' + )}\nexpirationTimerUpdate: ${JSON.stringify(expirationTimerUpdate)}` ); confirm?.(); return; @@ -445,9 +447,9 @@ export async function handleMessageJob( if (!lastDisappearingMessageChangeTimestamp) { window.log.debug( - `WIP: There is a problem with the expiration timer update. The lastDisappearingMessageChangeTimestamp is missing.\nmessage model: ${JSON.stringify( - messageModel - )}\n\nexpirationTimerUpdate: ${JSON.stringify(expirationTimerUpdate)}` + `The ExpirationTimerUpdate's lastDisappearingMessageChangeTimestamp is missing. message model: ${messageModel.get( + 'id' + )}\nexpirationTimerUpdate: ${JSON.stringify(expirationTimerUpdate)}` ); confirm?.(); return; @@ -464,9 +466,6 @@ export async function handleMessageJob( shouldCommitConvo: false, // NOTE we don't commit yet because we want to get the message id, see below }); - window.log.debug( - `WIP: [handleMessageJob] updating disappearing messages to expiratonModeUpdate: ${expirationModeUpdate} expireTimerUpdate: ${expireTimerUpdate}` - ); } else { // this does not commit to db nor UI unless we need to approve a convo await handleRegularMessage( diff --git a/ts/session/apis/snode_api/batchRequest.ts b/ts/session/apis/snode_api/batchRequest.ts index 99f3748c9..71210d239 100644 --- a/ts/session/apis/snode_api/batchRequest.ts +++ b/ts/session/apis/snode_api/batchRequest.ts @@ -21,11 +21,6 @@ export async function doSnodeBatchRequest( associatedWith: string | null, method: 'batch' | 'sequence' = 'batch' ): Promise { - // window.log.debug( - // `WIP: [doSnodeBatchRequest] "${method}":`, - // subRequests.map(m => m.method), - // subRequests - // ); const result = await snodeRpc({ method, params: { requests: subRequests }, diff --git a/ts/session/apis/snode_api/expireRequest.ts b/ts/session/apis/snode_api/expireRequest.ts index 09669c043..86d8df8b8 100644 --- a/ts/session/apis/snode_api/expireRequest.ts +++ b/ts/session/apis/snode_api/expireRequest.ts @@ -6,13 +6,13 @@ import { getSodiumRenderer } from '../../crypto'; import { StringUtils, UserUtils } from '../../utils'; import { fromBase64ToArray, fromHexToArray } from '../../utils/String'; import { EmptySwarmError } from '../../utils/errors'; +import { SeedNodeAPI } from '../seed_node_api'; import { UpdateExpiryOnNodeSubRequest } from './SnodeRequestTypes'; import { doSnodeBatchRequest } from './batchRequest'; import { GetNetworkTime } from './getNetworkTime'; import { getSwarmFor } from './snodePool'; import { SnodeSignature } from './snodeSignatures'; import { ExpireMessageResultItem, ExpireMessagesResultsContent } from './types'; -import { SeedNodeAPI } from '../seed_node_api'; export type verifyExpireMsgsResponseSignatureProps = ExpireMessageResultItem & { pubkey: string; @@ -30,8 +30,8 @@ export async function verifyExpireMsgsResponseSignature({ unchanged, }: verifyExpireMsgsResponseSignatureProps): Promise { if (!expiry || isEmpty(messageHashes) || isEmpty(signature)) { - window.log.warn( - `WIP: [verifyExpireMsgsSignature] missing argument\nexpiry:${expiry}\nmessageHashes:${messageHashes}\nsignature:${signature}` + window.log.error( + `[verifyExpireMsgsSignature] missing argument\nexpiry:${expiry}\nmessageHashes:${messageHashes}\nsignature:${signature}` ); return false; } @@ -50,7 +50,6 @@ export async function verifyExpireMsgsResponseSignature({ const verificationString = `${pubkey}${expiry}${hashes.join('')}`; const verificationData = StringUtils.encode(verificationString, 'utf8'); - // window.log.debug('WIP: [verifyExpireMsgsSignature] verificationString', verificationString); const sodium = await getSodiumRenderer(); try { @@ -62,7 +61,7 @@ export async function verifyExpireMsgsResponseSignature({ return isValid; } catch (e) { - window.log.warn('WIP: [verifyExpireMsgsSignature] failed with: ', e.message); + window.log.error('[verifyExpireMsgsSignature] operation failed with: ', e.message); return false; } } @@ -83,14 +82,13 @@ export async function processExpireRequestResponse( } const results: ExpireRequestResponseResults = {}; - // window.log.debug(`WIP: [processExpireRequestResponse] initial results: `, swarm, messageHashes); for (const nodeKey of Object.keys(swarm)) { if (!isEmpty(swarm[nodeKey].failed)) { window.log.warn( - `WIP: [processExpireRequestResponse] Swarm result failure on ${ + `[processExpireRequestResponse] Swarm result failure on ${ targetNode.pubkey_ed25519 - } for nodeKey ${nodeKey}\n${JSON.stringify(swarm[nodeKey])}` + } for nodeKey ${nodeKey}\n${JSON.stringify(swarm[nodeKey])} moving to next node` ); continue; } @@ -102,9 +100,9 @@ export async function processExpireRequestResponse( if (!updatedHashes || !expiry || !signature) { window.log.warn( - `WIP: [processExpireRequestResponse] Missing arguments on ${ + `[processExpireRequestResponse] Missing arguments on ${ targetNode.pubkey_ed25519 - } so we will ignore this result (${nodeKey}) and trust in the force.\n${JSON.stringify( + } so we will ignore this result on (${nodeKey}) and move onto the next node.\n${JSON.stringify( swarm[nodeKey] )}` ); @@ -123,10 +121,10 @@ export async function processExpireRequestResponse( }); if (!isValid) { - window.log.warn( - `WIP: [processExpireRequestResponse] Signature verification failed on ${ + window.log.error( + `[processExpireRequestResponse] Signature verification failed on ${ targetNode.pubkey_ed25519 - }!\n${JSON.stringify(messageHashes)}` + }\n${JSON.stringify(messageHashes)}` ); continue; } @@ -188,19 +186,8 @@ async function expireOnNodes( ); } - // window.log.debug( - // `WIP: [expireOnNodes] Success!\nHere are the results from one of the snodes.\nmessageHash: ${messageHash} \nexpiry: ${expiry} \nexpires at: ${new Date( - // expiry - // ).toUTCString()}\nnow: ${new Date(GetNetworkTime.getNowWithNetworkOffset()).toUTCString()}` - // ); - return expiry; } catch (err) { - window?.log?.warn( - 'WIP: [expireOnNodes]', - err.message || err, - `destination ${targetNode.ip}:${targetNode.port}` - ); // NOTE batch requests have their own retry logic which includes abort errors that will break our retry logic so we need to catch them and throw regular errors if (err instanceof pRetry.AbortError) { throw Error(err.message); @@ -224,7 +211,7 @@ export async function buildExpireRequest( if (extend && shorten) { window.log.error( - 'WIP: [buildExpireRequest] We cannot extend and shorten a message at the same time', + '[buildExpireRequest] We cannot extend and shorten a message at the same time', messageHash ); return null; @@ -235,16 +222,11 @@ export async function buildExpireRequest( const ourPubKey = UserUtils.getOurPubKeyStrFromCache(); if (!ourPubKey) { - window.log.error('WIP: [buildExpireRequest] No pubkey found', messageHash); + window.log.error('[buildExpireRequest] No pubkey found', messageHash); return null; } const expiry = GetNetworkTime.getNowWithNetworkOffset() + expireTimer; - // window.log.debug( - // `WIP: [buildExpireRequest]\nmessageHash: ${messageHash} should expire at ${new Date( - // expiry - // ).toUTCString()}` - // ); const signResult = await SnodeSignature.generateUpdateExpirySignature({ shortenOrExtend, timestamp: expiry, @@ -253,7 +235,7 @@ export async function buildExpireRequest( if (!signResult) { window.log.error( - `WIP: [buildExpireRequest] SnodeSignature.generateUpdateExpirySignature returned an empty result ${messageHash}` + `[buildExpireRequest] SnodeSignature.generateUpdateExpirySignature returned an empty result ${messageHash}` ); return null; } @@ -271,8 +253,6 @@ export async function buildExpireRequest( }, }; - // window.log.debug(`WIP: [buildExpireRequest] ${messageHash}\n${JSON.stringify(expireParams)}`); - return expireParams; } @@ -293,7 +273,7 @@ export async function expireMessageOnSnode( const ourPubKey = UserUtils.getOurPubKeyStrFromCache(); if (!ourPubKey) { - window.log.error('WIP: [expireMessageOnSnode] No pubkey found', messageHash); + window.log.error('[expireMessageOnSnode] No pubkey found', messageHash); return null; } @@ -321,7 +301,7 @@ export async function expireMessageOnSnode( minTimeout: SeedNodeAPI.getMinTimeout(), onFailedAttempt: e => { window?.log?.warn( - `WIP: [expireMessageOnSnode] expire message on snode attempt #${e.attemptNumber} failed. ${e.retriesLeft} retries left... Error: ${e.message}` + `[expireMessageOnSnode] expire message on snode attempt #${e.attemptNumber} failed. ${e.retriesLeft} retries left... Error: ${e.message}` ); }, } @@ -331,7 +311,7 @@ export async function expireMessageOnSnode( } catch (e) { const snodeStr = snode ? `${snode.ip}:${snode.port}` : 'null'; window?.log?.warn( - `WIP: [expireMessageOnSnode] ${e.code ? `${e.code} ` : ''}${e.message || + `[expireMessageOnSnode] ${e.code ? `${e.code} ` : ''}${e.message || e} by ${ourPubKey} for ${messageHash} via snode:${snodeStr}` ); throw e; diff --git a/ts/session/apis/snode_api/getExpiriesRequest.ts b/ts/session/apis/snode_api/getExpiriesRequest.ts index d035ae0b3..3072c2108 100644 --- a/ts/session/apis/snode_api/getExpiriesRequest.ts +++ b/ts/session/apis/snode_api/getExpiriesRequest.ts @@ -4,12 +4,12 @@ import pRetry from 'p-retry'; import { Snode } from '../../../data/data'; import { UserUtils } from '../../utils'; import { EmptySwarmError } from '../../utils/errors'; +import { SeedNodeAPI } from '../seed_node_api'; import { GetExpiriesFromNodeSubRequest } from './SnodeRequestTypes'; import { doSnodeBatchRequest } from './batchRequest'; import { getSwarmFor } from './snodePool'; import { SnodeSignature } from './snodeSignatures'; import { GetExpiriesResultsContent } from './types'; -import { SeedNodeAPI } from '../seed_node_api'; export type GetExpiriesRequestResponseResults = Record; @@ -25,18 +25,15 @@ export async function processGetExpiriesRequestResponse( } const results: GetExpiriesRequestResponseResults = {}; - // window.log.debug( - // `WIP: [processGetExpiriesRequestResponse] initial results:\nexpiries:${JSON.stringify( - // expiries - // )}` - // ); for (const messageHash of Object.keys(expiries)) { if (!expiries[messageHash]) { window.log.warn( - `WIP: [processGetExpiriesRequestResponse] Expiries result failure on ${ + `[processGetExpiriesRequestResponse] Expiries result failure on ${ targetNode.pubkey_ed25519 - } for messageHash ${messageHash}\n${JSON.stringify(expiries[messageHash])}` + } for messageHash ${messageHash}\n${JSON.stringify( + expiries[messageHash] + )} moving to the next node` ); continue; } @@ -45,9 +42,9 @@ export async function processGetExpiriesRequestResponse( if (!expiryMs) { window.log.warn( - `WIP: [processGetExpiriesRequestResponse] Missing expiry value on ${ + `[processGetExpiriesRequestResponse] Missing expiry value on ${ targetNode.pubkey_ed25519 - } so we will ignore this result (${messageHash}) and trust in the force.\n${JSON.stringify( + } so we will ignore this result (${messageHash}) and move onto the next node.\n${JSON.stringify( expiries[messageHash] )}` ); @@ -101,21 +98,8 @@ async function getExpiriesFromNodes( } const expiryTimestamps: Array = Object.values(expirationResults); - - window.log.debug( - `WIP: [getExpiriesFromNodes] Success!\nHere are the results.\nexpirationResults: ${Object.entries( - expirationResults - )}` - ); - return expiryTimestamps; } catch (err) { - window?.log?.warn( - 'WIP: [getExpiriesFromNodes] - send error:', - err.message || err, - `destination ${targetNode.ip}:${targetNode.port}` - ); - // NOTE batch requests have their own retry logic which includes abort errors that will break our retry logic so we need to catch them and throw regular errors if (err instanceof pRetry.AbortError) { throw Error(err.message); @@ -137,7 +121,7 @@ export async function buildGetExpiriesRequest( const ourPubKey = UserUtils.getOurPubKeyStrFromCache(); if (!ourPubKey) { - window.log.error('WIP: [buildGetExpiriesRequest] No pubkey found', messageHashes); + window.log.error('[buildGetExpiriesRequest] No pubkey found', messageHashes); return null; } @@ -148,7 +132,7 @@ export async function buildGetExpiriesRequest( if (!signResult) { window.log.error( - `WIP: [buildGetExpiriesRequest] SnodeSignature.generateUpdateExpirySignature returned an empty result ${messageHashes}` + `[buildGetExpiriesRequest] SnodeSignature.generateUpdateExpirySignature returned an empty result ${messageHashes}` ); return null; } @@ -164,10 +148,6 @@ export async function buildGetExpiriesRequest( }, }; - window.log.debug( - `WIP: [buildGetExpiriesRequest] getExpiriesParams: ${JSON.stringify(getExpiriesParams)}` - ); - return getExpiriesParams; } @@ -191,7 +171,7 @@ export async function getExpiriesFromSnode( const ourPubKey = UserUtils.getOurPubKeyStrFromCache(); if (!ourPubKey) { - window.log.error('WIP: [getExpiriesFromSnode] No pubkey found', messageHashes); + window.log.error('[getExpiriesFromSnode] No pubkey found', messageHashes); return []; } @@ -220,7 +200,7 @@ export async function getExpiriesFromSnode( minTimeout: SeedNodeAPI.getMinTimeout(), onFailedAttempt: e => { window?.log?.warn( - `WIP: [getExpiriesFromSnode] get expiries from snode attempt #${e.attemptNumber} failed. ${e.retriesLeft} retries left... Error: ${e.message}` + `[getExpiriesFromSnode] get expiries from snode attempt #${e.attemptNumber} failed. ${e.retriesLeft} retries left... Error: ${e.message}` ); }, } @@ -230,7 +210,7 @@ export async function getExpiriesFromSnode( } catch (e) { const snodeStr = snode ? `${snode.ip}:${snode.port}` : 'null'; window?.log?.warn( - `WIP: [getExpiriesFromSnode] ${e.code ? `${e.code} ` : ''}${e.message || + `[getExpiriesFromSnode] ${e.code ? `${e.code} ` : ''}${e.message || e} by ${ourPubKey} for ${messageHashes} via snode:${snodeStr}` ); throw e; diff --git a/ts/session/disappearing_messages/index.ts b/ts/session/disappearing_messages/index.ts index 62860a456..8520730f7 100644 --- a/ts/session/disappearing_messages/index.ts +++ b/ts/session/disappearing_messages/index.ts @@ -150,63 +150,63 @@ export const updateExpiringMessagesCheck = () => { export function setExpirationStartTimestamp( mode: DisappearingMessageConversationModeType, timestamp?: number, - callLocation?: string // this is for debugging purposes + // these are for debugging purposes + callLocation?: string, + messageId?: string ): number | undefined { let expirationStartTimestamp: number | undefined = GetNetworkTime.getNowWithNetworkOffset(); if (callLocation) { - window.log.debug(`WIP: [setExpirationStartTimestamp] called from: ${callLocation} `); + // window.log.debug(`[setExpirationStartTimestamp] called from: ${callLocation} ${messageId ? `messageId: ${messageId} ` : ''}`); } // TODO legacy messages support will be removed in a future release if (timestamp) { if (!isValidUnixTimestamp(timestamp)) { window.log.debug( - `WIP: [setExpirationStartTimestamp] We compared 2 timestamps for a disappearing message (${mode}) and the argument timestamp is invalid` + `[setExpirationStartTimestamp] We compared 2 timestamps for a disappearing message (${mode}) and the argument timestamp is not a invalid unix timestamp.${ + messageId ? `messageId: ${messageId} ` : '' + }` ); return undefined; } - window.log.debug( - `WIP: [setExpirationStartTimestamp] We compare 2 timestamps for a disappearing message (${mode}):\nexpirationStartTimestamp `, - new Date(expirationStartTimestamp).toLocaleTimeString(), - '\ntimestamp ', - new Date(timestamp).toLocaleTimeString() - ); expirationStartTimestamp = Math.min(expirationStartTimestamp, timestamp); } switch (mode) { case 'deleteAfterRead': - window.log.debug( - `WIP: [setExpirationStartTimestamp] We set the start timestamp for a delete after read message to ${new Date( - expirationStartTimestamp - ).toLocaleTimeString()}` - ); + // window.log.debug( + // `[setExpirationStartTimestamp] We set the start timestamp for a delete after read message to ${new Date( + // expirationStartTimestamp + // ).toLocaleTimeString()}${messageId ? `messageId: ${messageId} ` : ''}` + // ); break; case 'deleteAfterSend': - window.log.debug( - `WIP: [setExpirationStartTimestamp] We set the start timestamp for a delete after send message to ${new Date( - expirationStartTimestamp - ).toLocaleTimeString()}` - ); + // window.log.debug( + // `[setExpirationStartTimestamp] We set the start timestamp for a delete after send message to ${new Date( + // expirationStartTimestamp + // ).toLocaleTimeString()}${messageId ? `messageId: ${messageId} ` : ''}` + // ); break; // TODO legacy messages support will be removed in a future release case 'legacy': - window.log.debug( - `WIP: [setExpirationStartTimestamp] We set the start timestamp for a legacy message to ${new Date( - expirationStartTimestamp - ).toLocaleTimeString()}` - ); + // window.log.debug( + // `[setExpirationStartTimestamp] We set the start timestamp for a legacy message to ${new Date( + // expirationStartTimestamp + // ).toLocaleTimeString()} ${messageId ? `messageId: ${messageId} ` : ''}` + // ); break; case 'off': - window.log.debug( - 'WIP: [setExpirationStartTimestamp] Disappearing message mode has been turned off. We can safely ignore this.' - ); + // window.log.debug( + // `[setExpirationStartTimestamp] Disappearing message mode has been turned off. We can safely ignore this. ${messageId ? `messageId: ${messageId} ` : ''}` + // ); expirationStartTimestamp = undefined; break; default: window.log.debug( - `WIP: [setExpirationStartTimestamp] Invalid disappearing message mode "${mode}" set. Ignoring` + `[setExpirationStartTimestamp] Invalid disappearing message mode "${mode}" set. Ignoring.${ + messageId ? `messageId: ${messageId} ` : '' + }` ); expirationStartTimestamp = undefined; } @@ -320,12 +320,14 @@ export async function checkForExpireUpdateInContentMessage( convoToUpdate.getLastDisappearingMessageChangeTimestamp() >= lastDisappearingMessageChangeTimestamp)) ) { - window.log.info( - `WIP: checkForExpireUpdateInContentMessage() This is an outdated ${ + window.log.debug( + `[checkForExpireUpdateInContentMessage] This is an outdated ${ isOutgoing ? 'outgoing' : 'incoming' - } disappearing message setting. So we will ignore it.\nconvoToUpdate.getLastDisappearingMessageChangeTimestamp(): ${convoToUpdate.get( + } disappearing message setting for ${convoToUpdate.get( + 'id' + )}. So we will ignore it. Current lastDisappearingMessageChangeTimestamp: ${convoToUpdate.get( 'lastDisappearingMessageChangeTimestamp' - )}\nlastDisappearingMessageChangeTimestamp: ${lastDisappearingMessageChangeTimestamp}\n\ncontent: ${JSON.stringify( + )} New lastDisappearingMessageChangeTimestamp: ${lastDisappearingMessageChangeTimestamp}\n\ncontent: ${JSON.stringify( content )}` ); @@ -370,9 +372,11 @@ export async function checkForExpireUpdateInContentMessage( expirationTimer !== convoToUpdate.getExpireTimer() ) { window.log.debug( - `WIP: Received a legacy disappearing message before v2 was released without values set. Using the conversation settings.\ncontent: ${JSON.stringify( + `[checkForExpireUpdateInContentMessage] Received a legacy disappearing message before v2 was released for ${convoToUpdate.get( + 'id' + )}. Overriding it with the conversation disappearing settings.\ncontent: ${JSON.stringify( content - )}\n\nconvoToUpdate: ${JSON.stringify(convoToUpdate)}` + )}` ); expireUpdate.expirationTimer = convoToUpdate.getExpireTimer(); @@ -391,9 +395,9 @@ export async function checkForExpireUpdateInContentMessage( (isLegacyDataMessage || isLegacyConversationSettingMessage || shouldDisappearButIsntMessage) ) { window.log.debug( - `WIP: Received a legacy disappearing message after v2 was released. Overriding it with the conversation settings\ncontent: ${JSON.stringify( - content - )}\n\nconvoToUpdate: ${JSON.stringify(convoToUpdate)}` + `[checkForExpireUpdateInContentMessage] Received a legacy disappearing message after v2 was released for ${convoToUpdate.get( + 'id' + )}. Overriding it with the conversation settings\ncontent: ${JSON.stringify(content)}` ); expireUpdate.expirationTimer = convoToUpdate.getExpireTimer(); @@ -443,7 +447,9 @@ export function getMessageReadyToDisappear( expireUpdate?: DisappearingMessageUpdate ) { if (!expireUpdate) { - window.log.debug(`WIP: called getMessageReadyToDisappear() without an expireUpdate`); + // window.log.debug( + // `[getMessageReadyToDisappear] called getMessageReadyToDisappear() without an expireUpdate` + // ); return messageModel; } @@ -533,12 +539,12 @@ export async function updateMessageExpiryOnSwarm( shouldCommit?: boolean ) { if (callLocation) { - window.log.debug(`WIP: [updateMessageExpiryOnSwarm] called from: ${callLocation} `); + // window.log.debug(`[updateMessageExpiryOnSwarm] called from: ${callLocation} `); } if (!message.getExpirationType() || !message.getExpireTimer()) { window.log.debug( - `WIP: [updateMessageExpiryOnSwarm] Message ${message.get( + `[updateMessageExpiryOnSwarm] Message ${message.get( 'messageHash' )} has no expirationType or expireTimer set. Ignoring` ); @@ -548,13 +554,11 @@ export async function updateMessageExpiryOnSwarm( const messageHash = message.get('messageHash'); if (!messageHash) { window.log.debug( - `WIP: [updateMessageExpiryOnSwarm] Missing messageHash message: ${JSON.stringify(message)}` + `[updateMessageExpiryOnSwarm] Missing messageHash messageId: ${message.get('id')}` ); return message; } - // window.log.debug(`WIP: [updateMessageExpiryOnSwarm]\nmessage: ${JSON.stringify(message)}`); - const newTTL = await expireMessageOnSnode({ messageHash, expireTimer: message.getExpireTimer() * 1000, @@ -567,18 +571,12 @@ export async function updateMessageExpiryOnSwarm( expires_at: newTTL, }); - window.log.debug( - `WIP: [updateMessageExpiryOnSwarm] messageHash ${messageHash} has a new TTL of ${newTTL} which expires at ${new Date( - newTTL - ).toUTCString()}` - ); - if (shouldCommit) { await message.commit(); } } else { - window.log.warn( - `WIP: [updateMessageExpiryOnSwarm]\nmessageHash ${messageHash} has no new TTL.${ + window.log.debug( + `[updateMessageExpiryOnSwarm]\nmessageHash ${messageHash} has no new TTL.${ expiresAt ? `\nKeeping the old one ${expiresAt}which expires at ${new Date( expiresAt diff --git a/ts/session/sending/MessageSender.ts b/ts/session/sending/MessageSender.ts index f52dc8bc4..577d8b5c0 100644 --- a/ts/session/sending/MessageSender.ts +++ b/ts/session/sending/MessageSender.ts @@ -190,11 +190,6 @@ async function send( } await foundMessage.commit(); - // window?.log?.info( - // `WIP: updated message ${foundMessage.get('id')} with hash: ${foundMessage.get( - // 'messageHash' - // )}` - // ); } } diff --git a/ts/session/sending/MessageSentHandler.ts b/ts/session/sending/MessageSentHandler.ts index f1348ca59..a70a654ff 100644 --- a/ts/session/sending/MessageSentHandler.ts +++ b/ts/session/sending/MessageSentHandler.ts @@ -167,9 +167,9 @@ async function handleMessageSentFailure( fetchedMessage.set({ expirationStartTimestamp: undefined, }); - window.log.debug( - `WIP: [handleMessageSentFailure] Stopping a disappearing message from disppearing until we retry the send operation.\n${JSON.stringify( - fetchedMessage + window.log.warn( + `[handleMessageSentFailure] Stopping a message from disppearing until we retry the send operation. messageId: ${fetchedMessage.get( + 'id' )}` ); } diff --git a/ts/session/utils/sync/syncUtils.ts b/ts/session/utils/sync/syncUtils.ts index 9fdb3b265..8e8f44400 100644 --- a/ts/session/utils/sync/syncUtils.ts +++ b/ts/session/utils/sync/syncUtils.ts @@ -392,7 +392,6 @@ export const buildSyncMessage = ( expireUpdate.lastDisappearingMessageChangeTimestamp ) { if (expireUpdate.isOutdated) { - window.log.debug(`WIP: buildSyncMessage: \nexpireUpdate is outdated`); return null; } @@ -403,9 +402,6 @@ export const buildSyncMessage = ( syncTarget ); - // window.log.warn( - // `WIP: buildSyncMessage: \nexpireTimerSyncMessage: ${JSON.stringify(expireTimerSyncMessage)}` - // ); return expireTimerSyncMessage; } @@ -415,8 +411,5 @@ export const buildSyncMessage = ( timestamp, syncTarget ); - // window.log.warn( - // `WIP: buildSyncMessage: \nvisibleSyncMessage: ${JSON.stringify(visibleSyncMessage)}` - // ); return visibleSyncMessage; }; diff --git a/ts/util/releaseFeature.ts b/ts/util/releaseFeature.ts index 2be92d3ce..88eb32bab 100644 --- a/ts/util/releaseFeature.ts +++ b/ts/util/releaseFeature.ts @@ -123,7 +123,7 @@ export const ReleasedFeatures = { async function setIsFeatureReleased(featureName: FeatureNameTracked, value: boolean) { await Storage.put(featureStorageItemId(featureName), value); setIsFeatureReleasedCached(featureName, value); - window.log.debug(`WIP: setIsFeatureReleased: ${featureName} ${value}`); + window.log.debug(`WIP: [releaseFeature]: ${featureName} ${value}`); } window.setIsFeatureReleased = setIsFeatureReleased;