1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Fix compatability with v0 calls

https://github.com/matrix-org/matrix-js-sdk/pull/1567 introduced a
bug where we'd leave opponentPartyId undefined, but we compared it
to null later when testing for its presence.

Fixes https://github.com/vector-im/element-web/issues/16239
This commit is contained in:
David Baker
2021-01-25 16:09:39 +00:00
parent 15f968d5f8
commit e2d138cac6

View File

@@ -271,6 +271,9 @@ export class MatrixCall extends EventEmitter {
this.type = null; this.type = null;
this.forceTURN = opts.forceTURN; this.forceTURN = opts.forceTURN;
this.ourPartyId = this.client.deviceId; this.ourPartyId = this.client.deviceId;
// We compare this to null to checks the presence of a party ID:
// make sure it's null, not undefined
this.opponentPartyId = null;
// Array of Objects with urls, username, credential keys // Array of Objects with urls, username, credential keys
this.turnServers = opts.turnServers || []; this.turnServers = opts.turnServers || [];
if (this.turnServers.length === 0 && this.client.isFallbackICEServerAllowed()) { if (this.turnServers.length === 0 && this.client.isFallbackICEServerAllowed()) {
@@ -1364,7 +1367,7 @@ export class MatrixCall extends EventEmitter {
// party ID must match (our chosen partner hanging up the call) or be undefined (we haven't chosen // party ID must match (our chosen partner hanging up the call) or be undefined (we haven't chosen
// a partner yet but we're treating the hangup as a reject as per VoIP v0) // a partner yet but we're treating the hangup as a reject as per VoIP v0)
if (this.partyIdMatches(msg) || this.opponentPartyId === undefined || this.state === CallState.Ringing) { if (this.partyIdMatches(msg) || this.state === CallState.Ringing) {
// default reason is user_hangup // default reason is user_hangup
this.terminate(CallParty.Remote, msg.reason || CallErrorCode.UserHangup, true); this.terminate(CallParty.Remote, msg.reason || CallErrorCode.UserHangup, true);
} else { } else {
@@ -1468,6 +1471,11 @@ export class MatrixCall extends EventEmitter {
private async terminate(hangupParty: CallParty, hangupReason: CallErrorCode, shouldEmit: boolean) { private async terminate(hangupParty: CallParty, hangupReason: CallErrorCode, shouldEmit: boolean) {
if (this.callHasEnded()) return; if (this.callHasEnded()) return;
const stats = await this.peerConn.getStats();
for (const s of stats.keys()) {
console.log(stats.get(s));
}
if (this.inviteTimeout) { if (this.inviteTimeout) {
clearTimeout(this.inviteTimeout); clearTimeout(this.inviteTimeout);
this.inviteTimeout = null; this.inviteTimeout = null;