|
|
@ -92,7 +92,6 @@ export interface ConversationAttributes {
|
|
|
|
profile?: any;
|
|
|
|
profile?: any;
|
|
|
|
profileAvatar?: any;
|
|
|
|
profileAvatar?: any;
|
|
|
|
profileKey?: string;
|
|
|
|
profileKey?: string;
|
|
|
|
accessKey?: any;
|
|
|
|
|
|
|
|
triggerNotificationsFor: ConversationNotificationSettingType;
|
|
|
|
triggerNotificationsFor: ConversationNotificationSettingType;
|
|
|
|
isTrustedForAttachmentDownload: boolean;
|
|
|
|
isTrustedForAttachmentDownload: boolean;
|
|
|
|
isPinned: boolean;
|
|
|
|
isPinned: boolean;
|
|
|
@ -130,7 +129,6 @@ export interface ConversationAttributesOptionals {
|
|
|
|
profile?: any;
|
|
|
|
profile?: any;
|
|
|
|
profileAvatar?: any;
|
|
|
|
profileAvatar?: any;
|
|
|
|
profileKey?: string;
|
|
|
|
profileKey?: string;
|
|
|
|
accessKey?: any;
|
|
|
|
|
|
|
|
triggerNotificationsFor?: ConversationNotificationSettingType;
|
|
|
|
triggerNotificationsFor?: ConversationNotificationSettingType;
|
|
|
|
isTrustedForAttachmentDownload?: boolean;
|
|
|
|
isTrustedForAttachmentDownload?: boolean;
|
|
|
|
isPinned: boolean;
|
|
|
|
isPinned: boolean;
|
|
|
@ -1201,34 +1199,13 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
|
|
|
|
if (this.get('profileKey') !== profileKey) {
|
|
|
|
if (this.get('profileKey') !== profileKey) {
|
|
|
|
this.set({
|
|
|
|
this.set({
|
|
|
|
profileKey,
|
|
|
|
profileKey,
|
|
|
|
accessKey: null,
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
await this.deriveAccessKeyIfNeeded();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await this.commit();
|
|
|
|
await this.commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async deriveAccessKeyIfNeeded() {
|
|
|
|
|
|
|
|
const profileKey = this.get('profileKey');
|
|
|
|
|
|
|
|
if (!profileKey) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.get('accessKey')) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const profileKeyBuffer = fromBase64ToArrayBuffer(profileKey);
|
|
|
|
|
|
|
|
const accessKeyBuffer = await window.Signal.Crypto.deriveAccessKey(profileKeyBuffer);
|
|
|
|
|
|
|
|
const accessKey = fromArrayBufferToBase64(accessKeyBuffer);
|
|
|
|
|
|
|
|
this.set({ accessKey });
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
window?.log?.warn(`Failed to derive access key for ${this.id}`);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async upgradeMessages(messages: any) {
|
|
|
|
public async upgradeMessages(messages: any) {
|
|
|
|
// tslint:disable-next-line: one-variable-per-declaration
|
|
|
|
// tslint:disable-next-line: one-variable-per-declaration
|
|
|
|
for (let max = messages.length, i = 0; i < max; i += 1) {
|
|
|
|
for (let max = messages.length, i = 0; i < max; i += 1) {
|
|
|
|