Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"@playwright/test": "^1.61.1",
"@rollup/plugin-inject": "^5.0.5",
"@rollup/plugin-wasm": "^6.2.2",
"@sableclient/sable-call-embedded": "1.1.7",
"@sableclient/sable-call-embedded": "1.1.8",
"@sentry/vite-plugin": "^5.3.0",
"@tauri-apps/cli": "2.11.4",
"@testing-library/jest-dom": "^6.9.1",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions src/app/plugins/call/CallEmbed.intent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ describe('CallEmbed.getWidget', () => {
baseUrl: 'https://matrix.example.com',
getSafeUserId: () => '@alice:example.com',
getDeviceId: () => 'ALICEDEVICE',
matrixRTC: {
getRoomSession: () => ({
getOldestMembership: () => undefined,
memberships: [],
}),
},
} as never;

it('adds ring notification delegation for starting DM calls in non-call rooms', () => {
Expand Down Expand Up @@ -173,4 +179,44 @@ describe('CallEmbed.getWidget', () => {

expect(url.searchParams.get('parentUrl')).toBe('https://tauri.localhost');
});

it("forwards the ongoing call's livekit transport as livekitServiceUrl param", () => {
const oldest = {};
const mxWithOngoingCall = {
baseUrl: 'https://matrix.example.com',
getSafeUserId: () => '@alice:example.com',
getDeviceId: () => 'ALICEDEVICE',
matrixRTC: {
getRoomSession: () => ({
getOldestMembership: () => oldest,
memberships: [
{
getTransport: () => ({
type: 'livekit',
livekit_service_url: 'https://lk.example.org',
}),
},
],
}),
},
} as never;
const room = createRoom(false);
const widget = CallEmbed.getWidget(
mxWithOngoingCall,
room,
ElementCallIntent.JoinExisting,
'dark'
);
const url = new URL(widget.getCompleteUrl({ currentUserId: '@alice:example.com' }));

expect(url.searchParams.get('livekitServiceUrl')).toBe('https://lk.example.org');
});

it('adds no livekitServiceUrl param when there is no ongoing call', () => {
const room = createRoom(false);
const widget = CallEmbed.getWidget(mx, room, ElementCallIntent.StartCallVoice, 'dark');
const url = new URL(widget.getCompleteUrl({ currentUserId: '@alice:example.com' }));

expect(url.searchParams.get('livekitServiceUrl')).toBeNull();
});
});
17 changes: 17 additions & 0 deletions src/app/plugins/call/CallEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ export class CallEmbed {
);
}

// Widget-mode discovery can't reach a transport (no access token, iframe
// fetch restrictions), so forward the ongoing call's own transport.
private static getOngoingCallLivekitServiceUrl(mx: MatrixClient, room: Room): string | undefined {
const session = mx.matrixRTC.getRoomSession(room);
const oldest = session.getOldestMembership();
if (!oldest) return undefined;
const transport = session.memberships.map((m) => m.getTransport(oldest)).find(Boolean);
return transport?.type === 'livekit'
? (transport as { livekit_service_url?: string }).livekit_service_url
: undefined;
}

static getWidget(
mx: MatrixClient,
room: Room,
Expand Down Expand Up @@ -123,6 +135,11 @@ export class CallEmbed {
header: 'none',
});

const ongoingLivekitServiceUrl = CallEmbed.getOngoingCallLivekitServiceUrl(mx, room);
if (ongoingLivekitServiceUrl) {
params.append('livekitServiceUrl', ongoingLivekitServiceUrl);
}

if (!room.isCallRoom() && CallEmbed.startingCall(intent)) {
params.append('sendNotificationType', CallEmbed.dmCall(intent) ? 'ring' : 'notification');
params.append('waitForCallPickup', CallEmbed.dmCall(intent) ? 'true' : 'false');
Expand Down
Loading