diff --git a/src/matrixrtc/MatrixRTCSession.ts b/src/matrixrtc/MatrixRTCSession.ts index 9a61a7238b..4a1f4e0f23 100644 --- a/src/matrixrtc/MatrixRTCSession.ts +++ b/src/matrixrtc/MatrixRTCSession.ts @@ -50,6 +50,7 @@ import { } from "./RoomAndToDeviceKeyTransport.ts"; import { TypedReEmitter } from "../ReEmitter.ts"; import { ToDeviceKeyTransport } from "./ToDeviceKeyTransport.ts"; +import { M_TEXT } from "matrix-events-sdk"; /** * Events emitted by MatrixRTCSession @@ -98,6 +99,11 @@ export interface SessionConfig { * Determines the kind of call this will be. */ callIntent?: RTCCallIntent; + + /** + * An optional URL to be provided to allow guests to join the call via fallbacks. + */ + guestUrl?: () => string; } /** @@ -754,6 +760,7 @@ export class MatrixRTCSession extends TypedEventEmitter< response: ISendEventResponse; content: IRTCNotificationContent; }> => { + const guestUrl = this.joinConfig?.guestUrl?.() ?? ""; const content: IRTCNotificationContent = { "m.mentions": { user_ids: [], room: true }, "notification_type": notificationType, @@ -761,6 +768,12 @@ export class MatrixRTCSession extends TypedEventEmitter< event_id: parentEventId, rel_type: RelationType.Reference, }, + [M_TEXT.name]: [{ + body: `Starting a new ${callIntent === "voice" ? "voice": "video"} call.` + (guestUrl && `Join via ${guestUrl}`), + }, { + body: `Starting a new ${callIntent === "voice" ? "voice": "video"} call.` + (guestUrl && `Click here to join`), + mimetype: "text/html" + }], "sender_ts": Date.now(), "lifetime": 30_000, // 30 seconds }; diff --git a/src/matrixrtc/types.ts b/src/matrixrtc/types.ts index 08c32a2062..e7e38e1a3d 100644 --- a/src/matrixrtc/types.ts +++ b/src/matrixrtc/types.ts @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import type { IMentions } from "../matrix.ts"; +import type { IMentions, M_HTML, M_TEXT } from "../matrix.ts"; import type { RelationEvent } from "../types.ts"; import type { CallMembership } from "./CallMembership.ts"; @@ -112,6 +112,8 @@ export interface IRTCNotificationContent extends RelationEvent { "m.call.intent"?: RTCCallIntent; "sender_ts": number; "lifetime": number; + // Extensible event types + [M_TEXT.name]: {body: string, mimetype?: string}[]; } /**