Skip to content

Commit 0e0fba6

Browse files
robintowntoger5
andauthored
Send notification events when starting a call (#3248)
* Send notification events when starting a call Previously this has been the responsibility of the hosting application (Element Web / Element X), but I would like to move this responsibility to Element Call itself to make it even more lightweight to integrate Element Call into a widget-capable client. * use RTCNotification event * add url param * bump to latest js-sdk * remove everything decline related * use notification type in url params * fix url .md docs * back to `head=develop` and using js-sdk with send notification feature * format --------- Co-authored-by: Timo <toger5@hotmail.de>
1 parent 5ea0759 commit 0e0fba6

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

docs/url-params.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ These parameters are relevant to both [widget](./embedded-standalone.md) and [st
6969
| `skipLobby` (deprecated: use `intent` instead) | `true` or `false` | No. If `intent` is explicitly `start_call` then defaults to `true`. Otherwise defaults to `false` | No, defaults to `false` | Skips the lobby to join a call directly, can be combined with preload in widget. When `true` the audio and video inputs will be muted by default. (This means there currently is no way to start without muted video if one wants to skip the lobby. Also not in widget mode.) |
7070
| `theme` | One of: `light`, `dark`, `light-high-contrast`, `dark-high-contrast` | No, defaults to `dark` | No, defaults to `dark` | UI theme to use. |
7171
| `viaServers` | Comma separated list of [Matrix Server Names](https://spec.matrix.org/v1.12/appendices/#server-name) | Not applicable | No | Homeserver for joining a room, non-empty value required for rooms not on the user’s default homeserver. |
72+
| `sendNotificationType` | `ring` or `notification` | No | No | Will send a "ring" or "notification" `m.rtc.notification` event if the user is the first one in the call. |
7273

7374
### Widget-only parameters
7475

src/UrlParams.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Please see LICENSE in the repository root for full details.
88
import { useMemo } from "react";
99
import { useLocation } from "react-router-dom";
1010
import { logger } from "matrix-js-sdk/lib/logger";
11+
import { type RTCNotificationType } from "matrix-js-sdk/lib/matrixrtc";
1112

1213
import { Config } from "./config/Config";
1314
import { type EncryptionSystem } from "./e2ee/sharedKeyManagement";
@@ -193,6 +194,10 @@ export interface UrlParams {
193194
* The Sentry environment. This is only used in the embedded package of Element Call.
194195
*/
195196
sentryEnvironment: string | null;
197+
/**
198+
* Whether and what type of notification EC should send, when the user joins the call.
199+
*/
200+
sendNotificationType?: RTCNotificationType;
196201
}
197202

198203
// This is here as a stopgap, but what would be far nicer is a function that
@@ -275,6 +280,11 @@ export const getUrlParams = (
275280
? HeaderStyle.None
276281
: HeaderStyle.Standard);
277282

283+
const sendNotificationType = ["ring", "notification"].includes(
284+
parser.getParam("sendNotificationType") ?? "",
285+
)
286+
? (parser.getParam("sendNotificationType") as RTCNotificationType)
287+
: undefined;
278288
const widgetId = parser.getParam("widgetId");
279289
const parentUrl = parser.getParam("parentUrl");
280290
const isWidget = !!widgetId && !!parentUrl;
@@ -329,6 +339,7 @@ export const getUrlParams = (
329339
rageshakeSubmitUrl: parser.getParam("rageshakeSubmitUrl"),
330340
sentryDsn: parser.getParam("sentryDsn"),
331341
sentryEnvironment: parser.getParam("sentryEnvironment"),
342+
sendNotificationType,
332343
};
333344
};
334345

src/rtcSessionHelpers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { AutoDiscovery } from "matrix-js-sdk/lib/autodiscovery";
1818
import { PosthogAnalytics } from "./analytics/PosthogAnalytics";
1919
import { Config } from "./config/Config";
2020
import { ElementWidgetActions, widget, type WidgetHelpers } from "./widget";
21-
import { MatrixRTCFocusMissingError } from "./utils/errors.ts";
22-
import { getUrlParams } from "./UrlParams.ts";
21+
import { MatrixRTCFocusMissingError } from "./utils/errors";
22+
import { getUrlParams } from "./UrlParams";
2323

2424
const FOCI_WK_KEY = "org.matrix.msc4143.rtc_foci";
2525

@@ -116,6 +116,7 @@ export async function enterRTCSession(
116116
await makePreferredLivekitFoci(rtcSession, livekitAlias),
117117
makeActiveFocus(),
118118
{
119+
notificationType: getUrlParams().sendNotificationType,
119120
useNewMembershipManager,
120121
manageMediaKeys: encryptMedia,
121122
...(useDeviceSessionMemberEvents !== undefined && {

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10247,7 +10247,7 @@ __metadata:
1024710247

1024810248
"matrix-js-sdk@github:matrix-org/matrix-js-sdk#head=develop":
1024910249
version: 37.11.0
10250-
resolution: "matrix-js-sdk@https://github.com/matrix-org/matrix-js-sdk.git#commit=f8f1bf38373a944f12a739a301c1770c7bf08265"
10250+
resolution: "matrix-js-sdk@https://github.com/matrix-org/matrix-js-sdk.git#commit=aa79236ce23cef85583c802c0a9e8d1e77814d51"
1025110251
dependencies:
1025210252
"@babel/runtime": "npm:^7.12.5"
1025310253
"@matrix-org/matrix-sdk-crypto-wasm": "npm:^15.0.0"
@@ -10263,7 +10263,7 @@ __metadata:
1026310263
sdp-transform: "npm:^2.14.1"
1026410264
unhomoglyph: "npm:^1.0.6"
1026510265
uuid: "npm:11"
10266-
checksum: 10c0/e2090716731b04c52a6e23a6f06be59c39437c73f65b151d1c1d108c168f0fb1e3b6b23f229ddb0289cf3fb9cf304b4df63e84eae6ef198f29ee8d52f545c071
10266+
checksum: 10c0/33fb0918b0742c6a00ed0e4fd3cc958ae824d407f8e0e65687a011f8bbb058163e4123a7affce47368ca8489b96ccdceddfe98becc6a7c7aff7ab68b4e63a072
1026710267
languageName: node
1026810268
linkType: hard
1026910269

0 commit comments

Comments
 (0)