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

Fix temporary call messages being handled without call

In cases where a rogue client, or just a simple bug, sends a temporary
call message, like CallNegotiate the messages should just be discarded
if there's no actual p2p connection created.
This commit is contained in:
Dariusz Niemczyk
2021-08-09 12:43:00 +02:00
parent 946dcd0301
commit 9fe05e7d40
2 changed files with 13 additions and 3 deletions

View File

@@ -1286,7 +1286,7 @@ export class MatrixCall extends EventEmitter {
// https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Perfect_negotiation
const offerCollision = (
(description.type === 'offer') &&
(this.makingOffer || this.peerConn.signalingState != 'stable')
(this.makingOffer || this.peerConn.signalingState !== 'stable')
);
this.ignoreOffer = !polite && offerCollision;
@@ -1935,6 +1935,10 @@ export class MatrixCall extends EventEmitter {
}
}
}
get hasPeerConnection() {
return Boolean(this.peerConn);
}
}
async function getScreensharingStream(

View File

@@ -220,6 +220,7 @@ export class CallEventHandler {
} else {
this.client.emit("Call.incoming", call);
}
return;
} else if (type === EventType.CallCandidates) {
if (weSentTheEvent) return;
@@ -232,6 +233,7 @@ export class CallEventHandler {
} else {
call.onRemoteIceCandidatesReceived(event);
}
return;
} else if ([EventType.CallHangup, EventType.CallReject].includes(type)) {
// Note that we also observe our own hangups here so we can see
// if we've already rejected a call that would otherwise be valid
@@ -255,10 +257,14 @@ export class CallEventHandler {
this.calls.delete(content.call_id);
}
}
return;
}
// The following events need a call
if (!call) return;
// The following events need a call and a peer connection
if (!call && !call.hasPeerConnection) {
logger.warn('Discarding an event', type);
return;
}
// Ignore remote echo
if (event.getContent().party_id === call.ourPartyId) return;