Keeping profile data around longer in the face of errors
This commit is contained in:
parent
c97bb0feee
commit
850e759579
3 changed files with 31 additions and 50 deletions
|
@ -2356,8 +2356,6 @@ export async function startApp(): Promise<void> {
|
||||||
details.profileKey
|
details.profileKey
|
||||||
);
|
);
|
||||||
conversation.setProfileKey(profileKey);
|
conversation.setProfileKey(profileKey);
|
||||||
} else {
|
|
||||||
conversation.dropProfileKey();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof details.blocked !== 'undefined') {
|
if (typeof details.blocked !== 'undefined') {
|
||||||
|
|
1
ts/model-types.d.ts
vendored
1
ts/model-types.d.ts
vendored
|
@ -207,7 +207,6 @@ export type ConversationAttributesType = {
|
||||||
profileFamilyName?: string;
|
profileFamilyName?: string;
|
||||||
profileKey?: string;
|
profileKey?: string;
|
||||||
profileName?: string;
|
profileName?: string;
|
||||||
storageProfileKey?: string;
|
|
||||||
verified?: number;
|
verified?: number;
|
||||||
profileLastFetchedAt?: number;
|
profileLastFetchedAt?: number;
|
||||||
|
|
||||||
|
|
|
@ -4450,6 +4450,8 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
);
|
);
|
||||||
c.set('about', stringFromBytes(trimForDisplay(decrypted)));
|
c.set('about', stringFromBytes(trimForDisplay(decrypted)));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
c.unset('about');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.aboutEmoji) {
|
if (profile.aboutEmoji) {
|
||||||
|
@ -4462,11 +4464,16 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
);
|
);
|
||||||
c.set('aboutEmoji', stringFromBytes(trimForDisplay(decrypted)));
|
c.set('aboutEmoji', stringFromBytes(trimForDisplay(decrypted)));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
c.unset('aboutEmoji');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.capabilities) {
|
if (profile.capabilities) {
|
||||||
c.set({ capabilities: profile.capabilities });
|
c.set({ capabilities: profile.capabilities });
|
||||||
|
} else {
|
||||||
|
c.unset('capabilities');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profileCredentialRequestContext && profile.credential) {
|
if (profileCredentialRequestContext && profile.credential) {
|
||||||
const profileKeyCredential = handleProfileKeyCredential(
|
const profileKeyCredential = handleProfileKeyCredential(
|
||||||
clientZkProfileCipher,
|
clientZkProfileCipher,
|
||||||
|
@ -4474,18 +4481,28 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
profile.credential
|
profile.credential
|
||||||
);
|
);
|
||||||
c.set({ profileKeyCredential });
|
c.set({ profileKeyCredential });
|
||||||
|
} else {
|
||||||
|
c.unset('profileKeyCredential');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code !== 403 && error.code !== 404) {
|
switch (error?.code) {
|
||||||
window.log.warn(
|
case 403:
|
||||||
'getProfile failure:',
|
throw error;
|
||||||
c.idForLogging(),
|
case 404:
|
||||||
error && error.stack ? error.stack : error
|
window.log.warn(
|
||||||
);
|
`getProfile failure: failed to find a profile for ${c.idForLogging()}`,
|
||||||
} else {
|
error && error.stack ? error.stack : error
|
||||||
await c.dropProfileKey();
|
);
|
||||||
|
c.setUnregistered();
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
window.log.warn(
|
||||||
|
'getProfile failure:',
|
||||||
|
c.idForLogging(),
|
||||||
|
error && error.stack ? error.stack : error
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -4496,7 +4513,10 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
c.idForLogging(),
|
c.idForLogging(),
|
||||||
error && error.stack ? error.stack : error
|
error && error.stack ? error.stack : error
|
||||||
);
|
);
|
||||||
await c.dropProfileKey();
|
await c.set({
|
||||||
|
profileName: undefined,
|
||||||
|
profileFamilyName: undefined,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -4621,10 +4641,7 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
sealedSender: SEALED_SENDER.UNKNOWN,
|
sealedSender: SEALED_SENDER.UNKNOWN,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (
|
if (!viaStorageServiceSync) {
|
||||||
!viaStorageServiceSync &&
|
|
||||||
profileKey !== this.get('storageProfileKey')
|
|
||||||
) {
|
|
||||||
this.captureChange('profileKey');
|
this.captureChange('profileKey');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4637,39 +4654,6 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
Conversation: window.Whisper.Conversation,
|
Conversation: window.Whisper.Conversation,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viaStorageServiceSync) {
|
|
||||||
this.set({
|
|
||||||
storageProfileKey: profileKey,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async dropProfileKey(): Promise<void> {
|
|
||||||
if (this.get('profileKey')) {
|
|
||||||
window.log.info(
|
|
||||||
`Dropping profileKey, setting sealedSender to UNKNOWN for conversation ${this.idForLogging()}`
|
|
||||||
);
|
|
||||||
const profileAvatar = this.get('profileAvatar');
|
|
||||||
if (profileAvatar && profileAvatar.path) {
|
|
||||||
await deleteAttachmentData(profileAvatar.path);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.set({
|
|
||||||
about: undefined,
|
|
||||||
aboutEmoji: undefined,
|
|
||||||
profileKey: undefined,
|
|
||||||
profileKeyVersion: undefined,
|
|
||||||
profileKeyCredential: null,
|
|
||||||
accessKey: null,
|
|
||||||
profileName: undefined,
|
|
||||||
profileFamilyName: undefined,
|
|
||||||
profileAvatar: null,
|
|
||||||
sealedSender: SEALED_SENDER.UNKNOWN,
|
|
||||||
});
|
|
||||||
|
|
||||||
window.Signal.Data.updateConversation(this.attributes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async deriveAccessKeyIfNeeded(): Promise<void> {
|
async deriveAccessKeyIfNeeded(): Promise<void> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue