From a1be616e6f5a03f2f850cb41ae0b61a36313197e Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:44:14 -0700 Subject: [PATCH] Allow both UUIDv4/v7 for message ids --- ts/sql/Client.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ts/sql/Client.ts b/ts/sql/Client.ts index 891beffae5aa..7fda4b1d074c 100644 --- a/ts/sql/Client.ts +++ b/ts/sql/Client.ts @@ -18,7 +18,7 @@ import { cleanDataForIpc } from './cleanDataForIpc'; import type { AciString, ServiceIdString } from '../types/ServiceId'; import createTaskWithTimeout from '../textsecure/TaskWithTimeout'; import * as log from '../logging/log'; -import { isValidUuidV7 } from '../util/isValidUuid'; +import { isValidUuid, isValidUuidV7 } from '../util/isValidUuid'; import * as Errors from '../types/errors'; import type { StoredJob } from '../jobs/types'; @@ -603,7 +603,12 @@ async function saveMessage( jobToInsert: options.jobToInsert && formatJobForInsert(options.jobToInsert), }); - softAssert(isValidUuidV7(id), 'saveMessage: messageId is not a UUID'); + softAssert( + // Older messages still have `UUIDv4` so don't log errors when encountering + // it. + (!options.forceSave && isValidUuid(id)) || isValidUuidV7(id), + 'saveMessage: messageId is not a UUID' + ); void updateExpiringMessagesService(); void tapToViewMessagesDeletionService.update();