Outgoing call: Show safety number dialog if change detected

This commit is contained in:
Josh Perez 2020-08-26 16:30:10 -04:00 committed by Josh Perez
parent 45d829e439
commit 25dabd56fd
6 changed files with 61 additions and 12 deletions

View file

@ -393,19 +393,27 @@
onOutgoingAudioCallInConversation: async () => {
const conversation = this.model;
const isVideoCall = false;
await window.Signal.Services.calling.startOutgoingCall(
conversation,
isVideoCall
);
if (await this.isCallSafe()) {
await window.Signal.Services.calling.startOutgoingCall(
conversation,
isVideoCall
);
}
},
onOutgoingVideoCallInConversation: async () => {
const conversation = this.model;
const isVideoCall = true;
await window.Signal.Services.calling.startOutgoingCall(
conversation,
isVideoCall
);
if (await this.isCallSafe()) {
await window.Signal.Services.calling.startOutgoingCall(
conversation,
isVideoCall
);
}
},
onShowSafetyNumber: () => {
this.showSafetyNumber();
},
@ -2495,9 +2503,28 @@
}
},
showSendAnywayDialog(contacts) {
async isCallSafe() {
const contacts = await this.getUntrustedContacts();
if (contacts && contacts.length) {
const callAnyway = await this.showSendAnywayDialog(
contacts,
i18n('callAnyway')
);
if (!callAnyway) {
window.log.info(
'Safety number change dialog not accepted, new call not allowed.'
);
return false;
}
}
return true;
},
showSendAnywayDialog(contacts, confirmText) {
return new Promise(resolve => {
const dialog = new Whisper.SafetyNumberChangeDialogView({
confirmText,
contacts,
reject: () => {
resolve(false);

View file

@ -12,6 +12,7 @@
const dialog = new Whisper.ReactWrapperView({
Component: window.Signal.Components.SafetyNumberChangeDialog,
props: {
confirmText: options.confirmText,
contacts: options.contacts.map(contact => contact.cachedProps),
i18n: window.i18n,
onCancel: () => {