Fix bug where we'd remove profileKeyCredentials incorrectly

This commit is contained in:
Evan Hahn 2021-03-25 14:05:55 -05:00 committed by GitHub
parent afe135df0c
commit de5943a5fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,7 @@
/* eslint-disable class-methods-use-this */ /* eslint-disable class-methods-use-this */
/* eslint-disable camelcase */ /* eslint-disable camelcase */
import { ProfileKeyCredentialRequestContext } from 'zkgroup';
import { import {
MessageModelCollectionType, MessageModelCollectionType,
WhatIsThis, WhatIsThis,
@ -4363,8 +4364,10 @@ export class ConversationModel extends window.Backbone.Model<
const profileKeyVersionHex = c.get('profileKeyVersion')!; const profileKeyVersionHex = c.get('profileKeyVersion')!;
const existingProfileKeyCredential = c.get('profileKeyCredential'); const existingProfileKeyCredential = c.get('profileKeyCredential');
let profileKeyCredentialRequestHex; let profileKeyCredentialRequestHex: undefined | string;
let profileCredentialRequestContext; let profileCredentialRequestContext:
| undefined
| ProfileKeyCredentialRequestContext;
if ( if (
profileKey && profileKey &&
@ -4512,15 +4515,17 @@ export class ConversationModel extends window.Backbone.Model<
c.unset('capabilities'); c.unset('capabilities');
} }
if (profileCredentialRequestContext && profile.credential) { if (profileCredentialRequestContext) {
const profileKeyCredential = handleProfileKeyCredential( if (profile.credential) {
clientZkProfileCipher, const profileKeyCredential = handleProfileKeyCredential(
profileCredentialRequestContext, clientZkProfileCipher,
profile.credential profileCredentialRequestContext,
); profile.credential
c.set({ profileKeyCredential }); );
} else { c.set({ profileKeyCredential });
c.unset('profileKeyCredential'); } else {
c.unset('profileKeyCredential');
}
} }
} catch (error) { } catch (error) {
switch (error?.code) { switch (error?.code) {