Include ACI+Access Keys pairs with CDSI requests

This commit is contained in:
Fedor Indutny 2022-08-18 13:44:53 -07:00 committed by GitHub
parent 13046dc020
commit 757af2cbbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 145 additions and 144 deletions

View file

@ -8,6 +8,7 @@ import * as log from '../../logging/log';
import type { StateType as RootStateType } from '../reducer';
import type { UUIDStringType } from '../../types/UUID';
import { getUuidsForE164s } from '../../util/getUuidsForE164s';
import type { NoopActionType } from './noop';
@ -44,7 +45,8 @@ function checkForAccount(
AccountUpdateActionType | NoopActionType
> {
return async (dispatch, getState) => {
if (!window.textsecure.messaging) {
const { server } = window.textsecure;
if (!server) {
dispatch({
type: 'NOOP',
payload: null,
@ -77,16 +79,24 @@ function checkForAccount(
type: 'NOOP',
payload: null,
});
return;
}
let uuid: UUIDStringType | undefined;
log.info(`checkForAccount: looking ${phoneNumber} up on server`);
try {
const uuidLookup = await window.textsecure.messaging.getUuidsForE164s([
phoneNumber,
]);
uuid = uuidLookup[phoneNumber] || undefined;
const uuidLookup = await getUuidsForE164s(server, [phoneNumber]);
const maybePair = uuidLookup.get(phoneNumber);
if (maybePair) {
uuid = window.ConversationController.maybeMergeContacts({
aci: maybePair.aci,
pni: maybePair.pni,
e164: phoneNumber,
reason: 'checkForAccount',
})?.get('uuid');
}
} catch (error) {
log.error('checkForAccount:', Errors.toLogFormat(error));
}