Stop ringing and remove toast if another device answers a RTC call. (#30728)
* Stop ringing if another device answers a call. * Add test * fix check
This commit is contained in:
@@ -486,13 +486,27 @@ class NotifierClass extends TypedEventEmitter<keyof EmittedEvents, EmittedEvents
|
||||
private performCustomEventHandling(ev: MatrixEvent): void {
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const room = cli.getRoom(ev.getRoomId());
|
||||
const type = ev.getType();
|
||||
const thisUserHasConnectedDevice =
|
||||
room && MatrixRTCSession.callMembershipsForRoom(room).some((m) => m.sender === cli.getUserId());
|
||||
|
||||
if (EventType.GroupCallMemberPrefix === type && thisUserHasConnectedDevice) {
|
||||
const content = ev.getContent();
|
||||
|
||||
if (typeof content.call_id !== "string") {
|
||||
logger.warn(
|
||||
"Received malformatted GroupCallMemberPrefix event. Did not contain 'call_id' of type 'string'",
|
||||
);
|
||||
return;
|
||||
}
|
||||
// One of our devices has joined the call, so dismiss it.
|
||||
ToastStore.sharedInstance().dismissToast(getIncomingCallToastKey(content.call_id, room.roomId));
|
||||
}
|
||||
// Check maximum age (<= 15 seconds) of a call notify event that will trigger a ringing notification
|
||||
if (EventType.CallNotify === ev.getType() && (ev.getAge() ?? 0) < 15000 && !thisUserHasConnectedDevice) {
|
||||
else if (EventType.CallNotify === type && (ev.getAge() ?? 0) < 15000 && !thisUserHasConnectedDevice) {
|
||||
const content = ev.getContent();
|
||||
const roomId = ev.getRoomId();
|
||||
|
||||
if (typeof content.call_id !== "string") {
|
||||
logger.warn("Received malformatted CallNotify event. Did not contain 'call_id' of type 'string'");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user