From 1b88e45a425c24693cb8326f8eae2ccb57d8fa8e Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Fri, 18 Aug 2023 18:33:41 +0200 Subject: [PATCH] Fix persistence of username link data --- ts/sql/Client.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ts/sql/Client.ts b/ts/sql/Client.ts index 21f8b16a42..95134488c7 100644 --- a/ts/sql/Client.ts +++ b/ts/sql/Client.ts @@ -383,13 +383,7 @@ const ITEM_SPECS: Partial> = { senderCertificate: ['value.serialized'], senderCertificateNoE164: ['value.serialized'], subscriberId: ['value'], - usernameLink: { - key: 'value', - valueSpec: { - isMap: true, - valueSpec: ['entropy', 'serverId'], - }, - }, + usernameLink: ['value.entropy', 'value.serverId'], }; async function createOrUpdateItem( data: ItemType @@ -414,7 +408,12 @@ async function getItemById( const spec = ITEM_SPECS[id]; const data = await channels.getItemById(id); - return spec ? specToBytes(spec, data) : (data as unknown as ItemType); + try { + return spec ? specToBytes(spec, data) : (data as unknown as ItemType); + } catch (error) { + log.warn(`getItemById(${id}): Failed to parse item from spec`, error); + return undefined; + } } async function getAllItems(): Promise { const items = await channels.getAllItems();