Skip to content

Commit ffd3c95

Browse files
toger5hughns
andauthored
Remove support for "legacy" MSC3898 group calling in MatrixRTCSession and CallMembership (#4583)
* remove all legacy call related code and adjust tests. We actually had a bit of tests just for legacy and not for session events. All those tests got ported over so we do not remove any tests. * dont adjust tests but remove legacy tests * Remove deprecated CallMembership.getLocalExpiry() * Remove references to legacy in test case names * Clean up SessionMembershipData tsdoc * Remove CallMembership.expires * Use correct expire duration. * make expiration methods not return optional values and update docstring * add docs to `SessionMembershipData` * Use `MSC4143` (instaed of `non-legacy`) wording in comment Co-authored-by: Hugh Nimmo-Smith <[email protected]> * Incorporate feedback from review * Fix test name --------- Co-authored-by: Hugh Nimmo-Smith <[email protected]> Co-authored-by: Hugh Nimmo-Smith <[email protected]>
1 parent 7678923 commit ffd3c95

File tree

8 files changed

+241
-919
lines changed

8 files changed

+241
-919
lines changed

spec/unit/matrixrtc/CallMembership.spec.ts

+31-134
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ limitations under the License.
1515
*/
1616

1717
import { MatrixEvent } from "../../../src";
18-
import { CallMembership, CallMembershipDataLegacy, SessionMembershipData } from "../../../src/matrixrtc/CallMembership";
18+
import { CallMembership, SessionMembershipData } from "../../../src/matrixrtc/CallMembership";
1919

2020
function makeMockEvent(originTs = 0): MatrixEvent {
2121
return {
@@ -25,91 +25,15 @@ function makeMockEvent(originTs = 0): MatrixEvent {
2525
}
2626

2727
describe("CallMembership", () => {
28-
describe("CallMembershipDataLegacy", () => {
29-
const membershipTemplate: CallMembershipDataLegacy = {
30-
call_id: "",
31-
scope: "m.room",
32-
application: "m.call",
33-
device_id: "AAAAAAA",
34-
expires: 5000,
35-
membershipID: "bloop",
36-
foci_active: [{ type: "livekit" }],
37-
};
38-
it("rejects membership with no expiry and no expires_ts", () => {
39-
expect(() => {
40-
new CallMembership(
41-
makeMockEvent(),
42-
Object.assign({}, membershipTemplate, { expires: undefined, expires_ts: undefined }),
43-
);
44-
}).toThrow();
45-
});
46-
47-
it("rejects membership with no device_id", () => {
48-
expect(() => {
49-
new CallMembership(makeMockEvent(), Object.assign({}, membershipTemplate, { device_id: undefined }));
50-
}).toThrow();
51-
});
52-
53-
it("rejects membership with no call_id", () => {
54-
expect(() => {
55-
new CallMembership(makeMockEvent(), Object.assign({}, membershipTemplate, { call_id: undefined }));
56-
}).toThrow();
57-
});
58-
59-
it("allow membership with no scope", () => {
60-
expect(() => {
61-
new CallMembership(makeMockEvent(), Object.assign({}, membershipTemplate, { scope: undefined }));
62-
}).not.toThrow();
63-
});
64-
it("rejects with malformatted expires_ts", () => {
65-
expect(() => {
66-
new CallMembership(makeMockEvent(), Object.assign({}, membershipTemplate, { expires_ts: "string" }));
67-
}).toThrow();
68-
});
69-
it("rejects with malformatted expires", () => {
70-
expect(() => {
71-
new CallMembership(makeMockEvent(), Object.assign({}, membershipTemplate, { expires: "string" }));
72-
}).toThrow();
73-
});
74-
75-
it("uses event timestamp if no created_ts", () => {
76-
const membership = new CallMembership(makeMockEvent(12345), membershipTemplate);
77-
expect(membership.createdTs()).toEqual(12345);
78-
});
79-
80-
it("uses created_ts if present", () => {
81-
const membership = new CallMembership(
82-
makeMockEvent(12345),
83-
Object.assign({}, membershipTemplate, { created_ts: 67890 }),
84-
);
85-
expect(membership.createdTs()).toEqual(67890);
86-
});
87-
88-
it("computes absolute expiry time based on expires", () => {
89-
const membership = new CallMembership(makeMockEvent(1000), membershipTemplate);
90-
expect(membership.getAbsoluteExpiry()).toEqual(5000 + 1000);
91-
});
92-
93-
it("computes absolute expiry time based on expires_ts", () => {
94-
const membership = new CallMembership(
95-
makeMockEvent(1000),
96-
Object.assign({}, membershipTemplate, { expires_ts: 6000 }),
97-
);
98-
expect(membership.getAbsoluteExpiry()).toEqual(5000 + 1000);
28+
describe("SessionMembershipData", () => {
29+
beforeEach(() => {
30+
jest.useFakeTimers();
9931
});
10032

101-
it("returns preferred foci", () => {
102-
const fakeEvent = makeMockEvent();
103-
const mockFocus = { type: "this_is_a_mock_focus" };
104-
const membership = new CallMembership(
105-
fakeEvent,
106-
Object.assign({}, membershipTemplate, { foci_active: [mockFocus] }),
107-
);
108-
expect(membership.getPreferredFoci()).toEqual([mockFocus]);
33+
afterEach(() => {
34+
jest.useRealTimers();
10935
});
110-
});
11136

112-
describe("SessionMembershipData", () => {
11337
const membershipTemplate: SessionMembershipData = {
11438
call_id: "",
11539
scope: "m.room",
@@ -150,13 +74,6 @@ describe("CallMembership", () => {
15074
expect(membership.createdTs()).toEqual(67890);
15175
});
15276

153-
it("considers memberships unexpired if local age low enough", () => {
154-
const fakeEvent = makeMockEvent(1000);
155-
fakeEvent.getLocalAge = jest.fn().mockReturnValue(3000);
156-
const membership = new CallMembership(fakeEvent, membershipTemplate);
157-
expect(membership.isExpired()).toEqual(false);
158-
});
159-
16077
it("returns preferred foci", () => {
16178
const fakeEvent = makeMockEvent();
16279
const mockFocus = { type: "this_is_a_mock_focus" };
@@ -168,49 +85,29 @@ describe("CallMembership", () => {
16885
});
16986
});
17087

171-
describe("expiry calculation", () => {
172-
let fakeEvent: MatrixEvent;
173-
let membership: CallMembership;
174-
const membershipTemplate: CallMembershipDataLegacy = {
175-
call_id: "",
176-
scope: "m.room",
177-
application: "m.call",
178-
device_id: "AAAAAAA",
179-
expires: 5000,
180-
membershipID: "bloop",
181-
foci_active: [{ type: "livekit" }],
182-
};
183-
184-
beforeEach(() => {
185-
// server origin timestamp for this event is 1000
186-
fakeEvent = makeMockEvent(1000);
187-
membership = new CallMembership(fakeEvent!, membershipTemplate);
188-
189-
jest.useFakeTimers();
190-
});
191-
192-
afterEach(() => {
193-
jest.useRealTimers();
194-
});
195-
196-
it("converts expiry time into local clock", () => {
197-
// our clock would have been at 2000 at the creation time (our clock at event receive time - age)
198-
// (ie. the local clock is 1 second ahead of the servers' clocks)
199-
fakeEvent.localTimestamp = 2000;
200-
201-
// for simplicity's sake, we say that the event's age is zero
202-
fakeEvent.getLocalAge = jest.fn().mockReturnValue(0);
203-
204-
// for sanity's sake, make sure the server-relative expiry time is what we expect
205-
expect(membership.getAbsoluteExpiry()).toEqual(6000);
206-
// therefore the expiry time converted to our clock should be 1 second later
207-
expect(membership.getLocalExpiry()).toEqual(7000);
208-
});
209-
210-
it("calculates time until expiry", () => {
211-
jest.setSystemTime(2000);
212-
// should be using absolute expiry time
213-
expect(membership.getMsUntilExpiry()).toEqual(4000);
214-
});
215-
});
88+
// TODO: re-enable this test when expiry is implemented
89+
// eslint-disable-next-line jest/no-commented-out-tests
90+
// describe("expiry calculation", () => {
91+
// let fakeEvent: MatrixEvent;
92+
// let membership: CallMembership;
93+
94+
// beforeEach(() => {
95+
// // server origin timestamp for this event is 1000
96+
// fakeEvent = makeMockEvent(1000);
97+
// membership = new CallMembership(fakeEvent!, membershipTemplate);
98+
99+
// jest.useFakeTimers();
100+
// });
101+
102+
// afterEach(() => {
103+
// jest.useRealTimers();
104+
// });
105+
106+
// eslint-disable-next-line jest/no-commented-out-tests
107+
// it("calculates time until expiry", () => {
108+
// jest.setSystemTime(2000);
109+
// // should be using absolute expiry time
110+
// expect(membership.getMsUntilExpiry()).toEqual(DEFAULT_EXPIRE_DURATION - 1000);
111+
// });
112+
// });
216113
});

0 commit comments

Comments
 (0)