Add ringing for matrixRTC (#11870)
* Add ringing for matrixRTC - since we are using m.mentions we start with the Notifier - an event in the Notifier will result in a IncomingCall toast - incomingCallToast is responsible for ringing (as long as one can see the toast it rings) This should make sure visual and audio signal are in sync. Signed-off-by: Timo K <toger5@hotmail.de> * use typed CallNotifyContent Signed-off-by: Timo K <toger5@hotmail.de> * update tests Signed-off-by: Timo K <toger5@hotmail.de> * change to callId Signed-off-by: Timo K <toger5@hotmail.de> * fix tests Signed-off-by: Timo K <toger5@hotmail.de> * only ring in 1:1 calls notify in rooms < 15 member Signed-off-by: Timo K <toger5@hotmail.de> * call_id fallback Signed-off-by: Timo K <toger5@hotmail.de> * Update src/Notifier.ts Co-authored-by: Robin <robin@robin.town> * review Signed-off-by: Timo K <toger5@hotmail.de> * add tests Signed-off-by: Timo K <toger5@hotmail.de> * more tests Signed-off-by: Timo K <toger5@hotmail.de> * unused import Signed-off-by: Timo K <toger5@hotmail.de> * String -> string Signed-off-by: Timo K <toger5@hotmail.de> --------- Signed-off-by: Timo K <toger5@hotmail.de> Co-authored-by: Robin <robin@robin.town>
This commit is contained in:
parent
7ca0cd13d0
commit
a26c2d3c78
7 changed files with 230 additions and 50 deletions
|
@ -17,7 +17,15 @@ limitations under the License.
|
|||
import EventEmitter from "events";
|
||||
import { mocked } from "jest-mock";
|
||||
import { waitFor } from "@testing-library/react";
|
||||
import { RoomType, Room, RoomEvent, MatrixEvent, RoomStateEvent, PendingEventOrdering } from "matrix-js-sdk/src/matrix";
|
||||
import {
|
||||
RoomType,
|
||||
Room,
|
||||
RoomEvent,
|
||||
MatrixEvent,
|
||||
RoomStateEvent,
|
||||
PendingEventOrdering,
|
||||
UNSTABLE_ELEMENT_FUNCTIONAL_USERS,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
import { Widget } from "matrix-widget-api";
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { MatrixRTCSessionManagerEvents } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSessionManager";
|
||||
|
@ -982,4 +990,51 @@ describe("ElementCall", () => {
|
|||
call.off(CallEvent.Destroy, onDestroy);
|
||||
});
|
||||
});
|
||||
describe("create call", () => {
|
||||
function setFunctionalMembers(members: string[]) {
|
||||
room.currentState.setStateEvents([
|
||||
mkEvent({
|
||||
event: true,
|
||||
type: UNSTABLE_ELEMENT_FUNCTIONAL_USERS.name,
|
||||
user: "@user:example.com",
|
||||
room: room.roomId,
|
||||
skey: "",
|
||||
content: { service_members: members },
|
||||
}),
|
||||
]);
|
||||
}
|
||||
beforeEach(async () => {
|
||||
setFunctionalMembers(["@user:example.com", "@user2:example.com", "@user4:example.com"]);
|
||||
});
|
||||
it("sends notify event on create in a room with more than two members", async () => {
|
||||
const sendEventSpy = jest.spyOn(room.client, "sendEvent");
|
||||
await ElementCall.create(room);
|
||||
expect(sendEventSpy).toHaveBeenCalledWith("!1:example.org", "org.matrix.msc4075.call.notify", {
|
||||
"application": "m.call",
|
||||
"call_id": "",
|
||||
"m.mentions": { room: true, user_ids: [] },
|
||||
"notify_type": "notify",
|
||||
});
|
||||
});
|
||||
it("sends ring on create in a DM (two participants) room", async () => {
|
||||
setFunctionalMembers(["@user:example.com", "@user2:example.com"]);
|
||||
|
||||
const sendEventSpy = jest.spyOn(room.client, "sendEvent");
|
||||
await ElementCall.create(room);
|
||||
expect(sendEventSpy).toHaveBeenCalledWith("!1:example.org", "org.matrix.msc4075.call.notify", {
|
||||
"application": "m.call",
|
||||
"call_id": "",
|
||||
"m.mentions": { room: true, user_ids: [] },
|
||||
"notify_type": "ring",
|
||||
});
|
||||
});
|
||||
it("don't sent notify event if there are existing room call members", async () => {
|
||||
jest.spyOn(MatrixRTCSession, "callMembershipsForRoom").mockReturnValue([
|
||||
{ application: "m.call", callId: "" } as unknown as CallMembership,
|
||||
]);
|
||||
const sendEventSpy = jest.spyOn(room.client, "sendEvent");
|
||||
await ElementCall.create(room);
|
||||
expect(sendEventSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue