Skip to content

Commit

Permalink
Fix bug where we'd remove profileKeyCredentials incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn-Signal committed Mar 25, 2021
1 parent afe135d commit de5943a
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions ts/models/conversations.ts
Expand Up @@ -3,6 +3,7 @@

/* eslint-disable class-methods-use-this */
/* eslint-disable camelcase */
import { ProfileKeyCredentialRequestContext } from 'zkgroup';
import {
MessageModelCollectionType,
WhatIsThis,
Expand Down Expand Up @@ -4363,8 +4364,10 @@ export class ConversationModel extends window.Backbone.Model<
const profileKeyVersionHex = c.get('profileKeyVersion')!;
const existingProfileKeyCredential = c.get('profileKeyCredential');

let profileKeyCredentialRequestHex;
let profileCredentialRequestContext;
let profileKeyCredentialRequestHex: undefined | string;
let profileCredentialRequestContext:
| undefined
| ProfileKeyCredentialRequestContext;

if (
profileKey &&
Expand Down Expand Up @@ -4512,15 +4515,17 @@ export class ConversationModel extends window.Backbone.Model<
c.unset('capabilities');
}

if (profileCredentialRequestContext && profile.credential) {
const profileKeyCredential = handleProfileKeyCredential(
clientZkProfileCipher,
profileCredentialRequestContext,
profile.credential
);
c.set({ profileKeyCredential });
} else {
c.unset('profileKeyCredential');
if (profileCredentialRequestContext) {
if (profile.credential) {
const profileKeyCredential = handleProfileKeyCredential(
clientZkProfileCipher,
profileCredentialRequestContext,
profile.credential
);
c.set({ profileKeyCredential });
} else {
c.unset('profileKeyCredential');
}
}
} catch (error) {
switch (error?.code) {
Expand Down

0 comments on commit de5943a

Please sign in to comment.