-
-
Notifications
You must be signed in to change notification settings - Fork 649
[MatrixRTC] Use relation based call membership to compute create_ts()
#5031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
41a2f47
209eecd
6156d4c
b61e39a
ca4a9c6
29879e8
86f33f9
bb7c23d
8a5a8cd
25f4d6f
84a3d56
5bc970c
d94d02d
74b793c
e829a7b
f70cb14
a343e8c
11f610d
66f202a
4643844
8a21ff6
4bbb240
aa1cbe9
65a3461
e9dafb5
383b219
3c2f9b4
9946143
fb23833
b4abbfc
61b05a0
06a46ac
4608506
f4049a0
9308871
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,20 +17,24 @@ limitations under the License. | |
| import { EventEmitter } from "stream"; | ||
| import { type Mocked } from "jest-mock"; | ||
|
|
||
| import { EventType, type Room, RoomEvent, type MatrixClient, type MatrixEvent } from "../../../src"; | ||
| import { CallMembership, type SessionMembershipData } from "../../../src/matrixrtc/CallMembership"; | ||
| import { EventType, MatrixEvent, type Room, RoomEvent, type MatrixClient } from "../../../src"; | ||
| import { | ||
| CallMembership, | ||
| type RtcMembershipData, | ||
| type SessionMembershipData, | ||
| } from "../../../src/matrixrtc/CallMembership"; | ||
| import { secureRandomString } from "../../../src/randomstring"; | ||
|
|
||
| export type MembershipData = (SessionMembershipData | {}) & { user_id: string }; | ||
| export type MembershipData = (SessionMembershipData | RtcMembershipData | {}) & { user_id: string }; | ||
|
|
||
| export const membershipTemplate: SessionMembershipData & { user_id: string } = { | ||
| application: "m.call", | ||
| call_id: "", | ||
| user_id: "@mock:user.example", | ||
| device_id: "AAAAAAA", | ||
| scope: "m.room", | ||
| focus_active: { type: "livekit", focus_selection: "oldest_membership" }, | ||
| foci_preferred: [ | ||
| export const sessionMembershipTemplate: SessionMembershipData & { user_id: string } = { | ||
| "application": "m.call", | ||
| "call_id": "", | ||
| "user_id": "@mock:user.example", | ||
| "device_id": "AAAAAAA", | ||
| "scope": "m.room", | ||
| "focus_active": { type: "livekit", focus_selection: "oldest_membership" }, | ||
| "foci_preferred": [ | ||
| { | ||
| livekit_alias: "!alias:something.org", | ||
| livekit_service_url: "https://livekit-jwt.something.io", | ||
|
|
@@ -42,6 +46,16 @@ export const membershipTemplate: SessionMembershipData & { user_id: string } = { | |
| type: "livekit", | ||
| }, | ||
| ], | ||
| "m.call.intent": "voice", | ||
| }; | ||
|
|
||
| export const rtcMembershipTemplate: RtcMembershipData = { | ||
| slot_id: "m.call#", | ||
| application: { "type": "m.call", "m.call.id": "", "m.call.intent": "voice" }, | ||
| member: { user_id: "@alice:example.org", device_id: "AAAAAAA", id: "xyzHASHxyz" }, | ||
| rtc_transports: [{ type: "livekit" }], | ||
| msc4354_sticky_key: "my_sticky_key", | ||
| versions: [], | ||
| }; | ||
|
|
||
| export type MockClient = Pick< | ||
|
|
@@ -93,6 +107,7 @@ export function makeMockRoom( | |
| .mockImplementation(() => | ||
| useStickyEvents ? membershipData.map((m) => mockRTCEvent(m, roomId, 10000, ts)) : [], | ||
| ) as any, | ||
| findEventById: jest.fn(), | ||
| }); | ||
| return Object.assign(room, { | ||
| emitTimelineEvent: (event: MatrixEvent) => | ||
|
|
@@ -143,16 +158,15 @@ export function makeMockEvent( | |
| timestamp?: number, | ||
| stateKey?: string, | ||
| ): MatrixEvent { | ||
| return { | ||
| getType: jest.fn().mockReturnValue(type), | ||
| getContent: jest.fn().mockReturnValue(content), | ||
| getSender: jest.fn().mockReturnValue(sender), | ||
| getTs: jest.fn().mockReturnValue(timestamp ?? Date.now()), | ||
| getRoomId: jest.fn().mockReturnValue(roomId), | ||
| getId: jest.fn().mockReturnValue(secureRandomString(8)), | ||
| getStateKey: jest.fn().mockReturnValue(stateKey), | ||
| isDecryptionFailure: jest.fn().mockReturnValue(false), | ||
| } as unknown as MatrixEvent; | ||
| return new MatrixEvent({ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is just updating this method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh right, I was expecting to see a vi.mock() |
||
| event_id: secureRandomString(8), | ||
| sender, | ||
| type, | ||
| content, | ||
| room_id: roomId, | ||
| origin_server_ts: timestamp ?? 0, | ||
| state_key: stateKey, | ||
| }); | ||
| } | ||
|
|
||
| export function mockRTCEvent( | ||
|
|
@@ -175,7 +189,7 @@ export function mockRTCEvent( | |
| } | ||
|
|
||
| export function mockCallMembership(membershipData: MembershipData, roomId: string): CallMembership { | ||
| return new CallMembership(mockRTCEvent(membershipData, roomId), membershipData); | ||
| return new CallMembership(mockRTCEvent(membershipData, roomId)); | ||
| } | ||
|
|
||
| export function makeKey(id: number, key: string): { key: string; index: number } { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.