FIlter result of postBatchIdentityCheck

This commit is contained in:
trevor-signal
2026-08-18 11:40:06 -07:00
committed by GitHub
parent c8d7f48253
commit 7beb796adb
+14 -12
View File
@@ -2306,29 +2306,31 @@ export async function registerCapabilities(
export async function postBatchIdentityCheck(
elements: VerifyServiceIdRequestType
): Promise<VerifyServiceIdResponseType> {
const res = await _ajax({
const result = await _ajax({
host: 'chatService',
data: JSON.stringify({ elements }),
call: 'batchIdentityCheck',
httpType: 'POST',
unauthenticated: true,
responseType: 'json',
// TODO DESKTOP-8719
zodSchema: z.unknown(),
zodSchema: verifyServiceIdResponse,
});
const result = safeParseUnknown(verifyServiceIdResponse, res);
// Guard against server returning keys for uuids that we did not request
const submittedUuids = new Set(elements.map(el => el.uuid));
if (result.success) {
return result.data;
}
log.error(
'invalid response from postBatchIdentityCheck',
toLogFormat(result.error)
const filtered = result.elements.filter(uuidAndKeyHash =>
submittedUuids.has(uuidAndKeyHash.uuid)
);
throw result.error;
if (filtered.length !== result.elements.length) {
log.error(
'postBatchIdentityCheck: server returned ' +
`${result.elements.length - filtered.length} unrequested uuids`
);
}
return { elements: filtered };
}
function getProfileUrl(