Fix virtual / native room mapping on call transfers (#7848)

* Fix virtual / native room mapping on call transfers

By just sending them through the same code path as regular calls.

Also re-do the tests & add a test for transfer specifically.

* Optional arg

* Types
This commit is contained in:
David Baker 2022-02-21 12:17:09 +00:00 committed by GitHub
parent f1e1b7be86
commit 572fa99e67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 151 additions and 47 deletions

View file

@ -901,7 +901,7 @@ export default class CallHandler extends EventEmitter {
this.pause(AudioID.Ring);
}
public async dialNumber(number: string): Promise<void> {
public async dialNumber(number: string, transferee?: MatrixCall): Promise<void> {
const results = await this.pstnLookup(number);
if (!results || results.length === 0 || !results[0].userid) {
Modal.createTrackedDialog('', '', ErrorDialog, {
@ -932,12 +932,19 @@ export default class CallHandler extends EventEmitter {
metricsTrigger: "WebDialPad",
});
await this.placeMatrixCall(roomId, CallType.Voice, null);
await this.placeMatrixCall(roomId, CallType.Voice, transferee);
}
public async startTransferToPhoneNumber(
call: MatrixCall, destination: string, consultFirst: boolean,
): Promise<void> {
if (consultFirst) {
// if we're consulting, we just start by placing a call to the transfer
// target (passing the transferee so the actual tranfer can happen later)
this.dialNumber(destination, call);
return;
}
const results = await this.pstnLookup(destination);
if (!results || results.length === 0 || !results[0].userid) {
Modal.createTrackedDialog('', '', ErrorDialog, {