Fix persistence of username link data
This commit is contained in:
parent
90f0f8e255
commit
1b88e45a42
1 changed files with 7 additions and 8 deletions
|
@ -383,13 +383,7 @@ const ITEM_SPECS: Partial<Record<ItemKeyType, ObjectMappingSpecType>> = {
|
||||||
senderCertificate: ['value.serialized'],
|
senderCertificate: ['value.serialized'],
|
||||||
senderCertificateNoE164: ['value.serialized'],
|
senderCertificateNoE164: ['value.serialized'],
|
||||||
subscriberId: ['value'],
|
subscriberId: ['value'],
|
||||||
usernameLink: {
|
usernameLink: ['value.entropy', 'value.serverId'],
|
||||||
key: 'value',
|
|
||||||
valueSpec: {
|
|
||||||
isMap: true,
|
|
||||||
valueSpec: ['entropy', 'serverId'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
async function createOrUpdateItem<K extends ItemKeyType>(
|
async function createOrUpdateItem<K extends ItemKeyType>(
|
||||||
data: ItemType<K>
|
data: ItemType<K>
|
||||||
|
@ -414,7 +408,12 @@ async function getItemById<K extends ItemKeyType>(
|
||||||
const spec = ITEM_SPECS[id];
|
const spec = ITEM_SPECS[id];
|
||||||
const data = await channels.getItemById(id);
|
const data = await channels.getItemById(id);
|
||||||
|
|
||||||
return spec ? specToBytes(spec, data) : (data as unknown as ItemType<K>);
|
try {
|
||||||
|
return spec ? specToBytes(spec, data) : (data as unknown as ItemType<K>);
|
||||||
|
} catch (error) {
|
||||||
|
log.warn(`getItemById(${id}): Failed to parse item from spec`, error);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async function getAllItems(): Promise<AllItemsType> {
|
async function getAllItems(): Promise<AllItemsType> {
|
||||||
const items = await channels.getAllItems();
|
const items = await channels.getAllItems();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue