This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 830
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6534 from SimonBrandner/fix/ringing-sound/15591
Make the ringing sound mutable/disablable
- Loading branch information
Showing
3 changed files
with
26 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
/* | ||
Copyright 2015, 2016 OpenMarket Ltd | ||
Copyright 2017, 2018 New Vector Ltd | ||
Copyright 2019, 2020 The Matrix.org Foundation C.I.C. | ||
Copyright 2019 - 2021 The Matrix.org Foundation C.I.C. | ||
Copyright 2021 Šimon Brandner <[email protected]> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
|
@@ -85,6 +86,8 @@ import { randomUppercaseString, randomLowercaseString } from "matrix-js-sdk/src/ | |
import EventEmitter from 'events'; | ||
import SdkConfig from './SdkConfig'; | ||
import { ensureDMExists, findDMForUser } from './createRoom'; | ||
import { IPushRule, RuleId, TweakName, Tweaks } from "matrix-js-sdk/src/@types/PushRules"; | ||
import { PushProcessor } from 'matrix-js-sdk/src/pushprocessor'; | ||
import { WidgetLayoutStore, Container } from './stores/widgets/WidgetLayoutStore'; | ||
import { getIncomingCallToastKey } from './toasts/IncomingCallToast'; | ||
import ToastStore from './stores/ToastStore'; | ||
|
@@ -479,14 +482,28 @@ export default class CallHandler extends EventEmitter { | |
} | ||
|
||
switch (newState) { | ||
case CallState.Ringing: | ||
this.play(AudioID.Ring); | ||
case CallState.Ringing: { | ||
const incomingCallPushRule = ( | ||
new PushProcessor(MatrixClientPeg.get()).getPushRuleById(RuleId.IncomingCall) as IPushRule | ||
); | ||
const pushRuleEnabled = incomingCallPushRule?.enabled; | ||
const tweakSetToRing = incomingCallPushRule?.actions.some((action: Tweaks) => ( | ||
action.set_tweak === TweakName.Sound && | ||
action.value === "ring" | ||
)); | ||
|
||
if (pushRuleEnabled && tweakSetToRing) { | ||
this.play(AudioID.Ring); | ||
} else { | ||
this.silenceCall(call.callId); | ||
} | ||
break; | ||
case CallState.InviteSent: | ||
} | ||
case CallState.InviteSent: { | ||
this.play(AudioID.Ringback); | ||
break; | ||
case CallState.Ended: | ||
{ | ||
} | ||
case CallState.Ended: { | ||
const hangupReason = call.hangupReason; | ||
Analytics.trackEvent('voip', 'callEnded', 'hangupReason', hangupReason); | ||
this.removeCallForRoom(mappedRoomId); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters