1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2026-01-03 23:22:30 +03:00

Add extensible event fallback for call notifications.

This commit is contained in:
Will Hunt
2025-10-16 13:46:19 +02:00
parent 502a513b5b
commit 21c73b0140
2 changed files with 16 additions and 1 deletions

View File

@@ -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"}</b> call.` + (guestUrl && `<a href="${guestUrl}">Click here to join</a>`),
mimetype: "text/html"
}],
"sender_ts": Date.now(),
"lifetime": 30_000, // 30 seconds
};

View File

@@ -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}[];
}
/**