When incoming message should've been sealed sender, reply with profile key

This commit is contained in:
Evan Hahn 2021-05-05 11:39:16 -05:00 committed by GitHub
parent 18c86898d1
commit 8ef14e6f39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 384 additions and 38 deletions

View file

@ -54,6 +54,7 @@ import {
SerializedCertificateType,
} from '../textsecure/OutgoingMessage';
import { senderCertificateService } from '../services/senderCertificate';
import { ourProfileKeyService } from '../services/ourProfileKey';
/* eslint-disable more/no-then */
window.Whisper = window.Whisper || {};
@ -3033,11 +3034,6 @@ export class ConversationModel extends window.Backbone
const destination = this.getSendTarget()!;
const recipients = this.getRecipients();
let profileKey: ArrayBuffer | undefined;
if (this.get('profileSharing')) {
profileKey = window.storage.get('profileKey');
}
return this.queueJob(async () => {
window.log.info(
'Sending deleteForEveryone to conversation',
@ -3073,7 +3069,12 @@ export class ConversationModel extends window.Backbone
const options = await this.getSendOptions();
const promise = (() => {
const promise = (async () => {
let profileKey: ArrayBuffer | undefined;
if (this.get('profileSharing')) {
profileKey = await ourProfileKeyService.get();
}
if (this.isPrivate()) {
return window.textsecure.messaging.sendMessageToIdentifier(
destination,
@ -3143,11 +3144,6 @@ export class ConversationModel extends window.Backbone
const destination = this.getSendTarget()!;
const recipients = this.getRecipients();
let profileKey: ArrayBuffer | undefined;
if (this.get('profileSharing')) {
profileKey = window.storage.get('profileKey');
}
return this.queueJob(async () => {
window.log.info(
'Sending reaction to conversation',
@ -3185,6 +3181,11 @@ export class ConversationModel extends window.Backbone
throw new Error('Cannot send reaction while offline!');
}
let profileKey: ArrayBuffer | undefined;
if (this.get('profileSharing')) {
profileKey = await ourProfileKeyService.get();
}
// Special-case the self-send case - we send only a sync message
if (this.isMe()) {
const dataMessage = await window.textsecure.messaging.getMessageProto(
@ -3262,7 +3263,13 @@ export class ConversationModel extends window.Backbone
return;
}
window.log.info('Sending profileKeyUpdate to conversation', id, recipients);
const profileKey = window.storage.get('profileKey');
const profileKey = await ourProfileKeyService.get();
if (!profileKey) {
window.log.error(
'Attempted to send profileKeyUpdate but our profile key was not found'
);
return;
}
await window.textsecure.messaging.sendProfileKeyUpdate(
profileKey,
recipients,
@ -3301,11 +3308,6 @@ export class ConversationModel extends window.Backbone
const expireTimer = this.get('expireTimer');
const recipients = this.getRecipients();
let profileKey: ArrayBuffer | undefined;
if (this.get('profileSharing')) {
profileKey = window.storage.get('profileKey');
}
this.queueJob(async () => {
const now = Date.now();
@ -3399,6 +3401,11 @@ export class ConversationModel extends window.Backbone
now,
});
let profileKey: ArrayBuffer | undefined;
if (this.get('profileSharing')) {
profileKey = await ourProfileKeyService.get();
}
// Special-case the self-send case - we send only a sync message
if (this.isMe()) {
const dataMessage = await window.textsecure.messaging.getMessageProto(
@ -4035,11 +4042,13 @@ export class ConversationModel extends window.Backbone
return message;
}
const sendOptions = await this.getSendOptions();
let profileKey;
if (this.get('profileSharing')) {
profileKey = window.storage.get('profileKey');
profileKey = await ourProfileKeyService.get();
}
const sendOptions = await this.getSendOptions();
let promise;
if (this.isMe()) {