Harden UUID-handling code paths

This commit is contained in:
Ken Powers 2020-06-12 18:36:32 -04:00 committed by Scott Nonnenberg
parent d3a27a6442
commit bf04c9114e
10 changed files with 193 additions and 124 deletions

View file

@ -693,19 +693,14 @@ export default class AccountManager extends EventTarget {
async registrationDone({ uuid, number }: { uuid?: string; number?: string }) {
window.log.info('registration done');
const identifier = number || uuid;
if (!identifier) {
throw new Error('registrationDone: no identifier!');
const conversationId = window.ConversationController.ensureContactIds({
e164: number,
uuid,
});
if (!conversationId) {
throw new Error('registrationDone: no conversationId!');
}
// Ensure that we always have a conversation for ourself
const conversation = await window.ConversationController.getOrCreateAndWait(
identifier,
'private'
);
conversation.updateE164(number);
conversation.updateUuid(uuid);
window.log.info('dispatching registration event');
this.dispatchEvent(new Event('registration'));