mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
use notification type in url params
This commit is contained in:
@@ -8,6 +8,7 @@ Please see LICENSE in the repository root for full details.
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
import { logger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
|
import { type RTCNotificationType } from "matrix-js-sdk/lib/matrixrtc";
|
||||||
|
|
||||||
import { Config } from "./config/Config";
|
import { Config } from "./config/Config";
|
||||||
import { type EncryptionSystem } from "./e2ee/sharedKeyManagement";
|
import { type EncryptionSystem } from "./e2ee/sharedKeyManagement";
|
||||||
@@ -194,13 +195,9 @@ export interface UrlParams {
|
|||||||
*/
|
*/
|
||||||
sentryEnvironment: string | null;
|
sentryEnvironment: string | null;
|
||||||
/**
|
/**
|
||||||
* Whether to send a notification when the user joins the call.
|
* Whether and what type of notification EC should send, when the user joins the call.
|
||||||
* This does all the necessary logic to check if it is actually appropriate to send the notification,
|
|
||||||
* - is it the first joiner
|
|
||||||
* - it it a 1:1 room
|
|
||||||
* - ...
|
|
||||||
*/
|
*/
|
||||||
sendNotification: boolean;
|
sendNotificationType?: RTCNotificationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is here as a stopgap, but what would be far nicer is a function that
|
// This is here as a stopgap, but what would be far nicer is a function that
|
||||||
@@ -283,6 +280,11 @@ export const getUrlParams = (
|
|||||||
? HeaderStyle.None
|
? HeaderStyle.None
|
||||||
: HeaderStyle.Standard);
|
: HeaderStyle.Standard);
|
||||||
|
|
||||||
|
const sendNotificationType = ["ring", "notification"].includes(
|
||||||
|
parser.getParam("sendNotificationType") ?? "",
|
||||||
|
)
|
||||||
|
? (parser.getParam("sendNotificationType") as RTCNotificationType)
|
||||||
|
: undefined;
|
||||||
const widgetId = parser.getParam("widgetId");
|
const widgetId = parser.getParam("widgetId");
|
||||||
const parentUrl = parser.getParam("parentUrl");
|
const parentUrl = parser.getParam("parentUrl");
|
||||||
const isWidget = !!widgetId && !!parentUrl;
|
const isWidget = !!widgetId && !!parentUrl;
|
||||||
@@ -337,7 +339,7 @@ export const getUrlParams = (
|
|||||||
rageshakeSubmitUrl: parser.getParam("rageshakeSubmitUrl"),
|
rageshakeSubmitUrl: parser.getParam("rageshakeSubmitUrl"),
|
||||||
sentryDsn: parser.getParam("sentryDsn"),
|
sentryDsn: parser.getParam("sentryDsn"),
|
||||||
sentryEnvironment: parser.getParam("sentryEnvironment"),
|
sentryEnvironment: parser.getParam("sentryEnvironment"),
|
||||||
sendNotification: parser.getFlagParam("sendNotification"),
|
sendNotificationType,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ Please see LICENSE in the repository root for full details.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type RTCNotificationType,
|
|
||||||
type MatrixRTCSession,
|
type MatrixRTCSession,
|
||||||
} from "matrix-js-sdk/lib/matrixrtc";
|
} from "matrix-js-sdk/lib/matrixrtc";
|
||||||
import { logger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
@@ -17,14 +16,12 @@ import {
|
|||||||
type LivekitFocusActive,
|
type LivekitFocusActive,
|
||||||
} from "matrix-js-sdk/lib/matrixrtc";
|
} from "matrix-js-sdk/lib/matrixrtc";
|
||||||
import { AutoDiscovery } from "matrix-js-sdk/lib/autodiscovery";
|
import { AutoDiscovery } from "matrix-js-sdk/lib/autodiscovery";
|
||||||
import { type Room } from "matrix-js-sdk";
|
|
||||||
|
|
||||||
import { PosthogAnalytics } from "./analytics/PosthogAnalytics";
|
import { PosthogAnalytics } from "./analytics/PosthogAnalytics";
|
||||||
import { Config } from "./config/Config";
|
import { Config } from "./config/Config";
|
||||||
import { ElementWidgetActions, widget, type WidgetHelpers } from "./widget";
|
import { ElementWidgetActions, widget, type WidgetHelpers } from "./widget";
|
||||||
import { MatrixRTCFocusMissingError } from "./utils/errors";
|
import { MatrixRTCFocusMissingError } from "./utils/errors";
|
||||||
import { getUrlParams } from "./UrlParams";
|
import { getUrlParams } from "./UrlParams";
|
||||||
import { getJoinedNonFunctionalMembers } from "./utils/matrix";
|
|
||||||
|
|
||||||
const FOCI_WK_KEY = "org.matrix.msc4143.rtc_foci";
|
const FOCI_WK_KEY = "org.matrix.msc4143.rtc_foci";
|
||||||
|
|
||||||
@@ -99,12 +96,6 @@ async function makePreferredLivekitFoci(
|
|||||||
// if (focusOtherMembers) preferredFoci.push(focusOtherMembers);
|
// if (focusOtherMembers) preferredFoci.push(focusOtherMembers);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRTCNotificationType(room: Room): RTCNotificationType | undefined {
|
|
||||||
if (room.isCallRoom()) return undefined;
|
|
||||||
if (getJoinedNonFunctionalMembers(room).length === 2) return "ring";
|
|
||||||
return "notification";
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function enterRTCSession(
|
export async function enterRTCSession(
|
||||||
rtcSession: MatrixRTCSession,
|
rtcSession: MatrixRTCSession,
|
||||||
encryptMedia: boolean,
|
encryptMedia: boolean,
|
||||||
@@ -127,7 +118,7 @@ export async function enterRTCSession(
|
|||||||
await makePreferredLivekitFoci(rtcSession, livekitAlias),
|
await makePreferredLivekitFoci(rtcSession, livekitAlias),
|
||||||
makeActiveFocus(),
|
makeActiveFocus(),
|
||||||
{
|
{
|
||||||
notificationType: getRTCNotificationType(rtcSession.room),
|
notificationType: getUrlParams().sendNotificationType,
|
||||||
useNewMembershipManager,
|
useNewMembershipManager,
|
||||||
manageMediaKeys: encryptMedia,
|
manageMediaKeys: encryptMedia,
|
||||||
...(useDeviceSessionMemberEvents !== undefined && {
|
...(useDeviceSessionMemberEvents !== undefined && {
|
||||||
|
|||||||
@@ -12,10 +12,7 @@ import {
|
|||||||
IndexedDBStore,
|
IndexedDBStore,
|
||||||
MemoryStore,
|
MemoryStore,
|
||||||
Preset,
|
Preset,
|
||||||
type RoomMember,
|
|
||||||
UNSTABLE_ELEMENT_FUNCTIONAL_USERS,
|
|
||||||
Visibility,
|
Visibility,
|
||||||
Direction,
|
|
||||||
} from "matrix-js-sdk";
|
} from "matrix-js-sdk";
|
||||||
import { type ISyncStateData, type SyncState } from "matrix-js-sdk/lib/sync";
|
import { type ISyncStateData, type SyncState } from "matrix-js-sdk/lib/sync";
|
||||||
import { logger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
@@ -339,27 +336,6 @@ export function getRelativeRoomUrl(
|
|||||||
return `/room/#${roomPart}?${generateUrlSearchParams(roomId, encryptionSystem, viaServers).toString()}`;
|
return `/room/#${roomPart}?${generateUrlSearchParams(roomId, encryptionSystem, viaServers).toString()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all room members that are non-functional (all actual room members).
|
|
||||||
* A functional user is a user that is not a real user, but a bot, assistant, etc.
|
|
||||||
*/
|
|
||||||
export function getJoinedNonFunctionalMembers(room: Room): RoomMember[] {
|
|
||||||
const functionalUsersStateEvent = room
|
|
||||||
.getLiveTimeline()
|
|
||||||
.getState(Direction.Forward)
|
|
||||||
?.getStateEvents(UNSTABLE_ELEMENT_FUNCTIONAL_USERS.name, "");
|
|
||||||
|
|
||||||
const functionalMembers = Array.isArray(
|
|
||||||
functionalUsersStateEvent?.getContent().service_members,
|
|
||||||
)
|
|
||||||
? functionalUsersStateEvent.getContent().service_members
|
|
||||||
: [];
|
|
||||||
|
|
||||||
return room
|
|
||||||
.getJoinedMembers()
|
|
||||||
.filter((m) => !functionalMembers.includes(m.userId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a network operation with retries on ConnectionError.
|
* Perform a network operation with retries on ConnectionError.
|
||||||
* If the error is not retryable, or the max number of retries is reached, the error is rethrown.
|
* If the error is not retryable, or the max number of retries is reached, the error is rethrown.
|
||||||
|
|||||||
Reference in New Issue
Block a user