You've already forked matrix-js-sdk
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:
@@ -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
|
||||
};
|
||||
|
||||
@@ -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}[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user