mirror of https://github.com/vector-im/riot-web
Fix misunderstanding of functional members (#11918)
* fix misunderstanding of functional members Signed-off-by: Timo K <toger5@hotmail.de> * unused import Signed-off-by: Timo K <toger5@hotmail.de> --------- Signed-off-by: Timo K <toger5@hotmail.de>pull/28788/head^2
parent
52e3e0de1f
commit
b5178e3733
|
@ -53,7 +53,7 @@ import { getCurrentLanguage } from "../languageHandler";
|
||||||
import { FontWatcher } from "../settings/watchers/FontWatcher";
|
import { FontWatcher } from "../settings/watchers/FontWatcher";
|
||||||
import { PosthogAnalytics } from "../PosthogAnalytics";
|
import { PosthogAnalytics } from "../PosthogAnalytics";
|
||||||
import { UPDATE_EVENT } from "../stores/AsyncStore";
|
import { UPDATE_EVENT } from "../stores/AsyncStore";
|
||||||
import { getFunctionalMembers } from "../utils/room/getFunctionalMembers";
|
import { getJoinedNonFunctionalMembers } from "../utils/room/getJoinedNonFunctionalMembers";
|
||||||
|
|
||||||
const TIMEOUT_MS = 16000;
|
const TIMEOUT_MS = 16000;
|
||||||
|
|
||||||
|
@ -773,7 +773,7 @@ export class ElementCall extends Call {
|
||||||
|
|
||||||
// We only want to ring in rooms that have less or equal to NOTIFY_MEMBER_LIMIT participants. For really large rooms we don't want to ring.
|
// We only want to ring in rooms that have less or equal to NOTIFY_MEMBER_LIMIT participants. For really large rooms we don't want to ring.
|
||||||
const NOTIFY_MEMBER_LIMIT = 15;
|
const NOTIFY_MEMBER_LIMIT = 15;
|
||||||
const memberCount = getFunctionalMembers(room).length;
|
const memberCount = getJoinedNonFunctionalMembers(room).length;
|
||||||
if (!isVideoRoom && existingRoomCallMembers.length == 0 && memberCount <= NOTIFY_MEMBER_LIMIT) {
|
if (!isVideoRoom && existingRoomCallMembers.length == 0 && memberCount <= NOTIFY_MEMBER_LIMIT) {
|
||||||
// send ringing event
|
// send ringing event
|
||||||
const content: ICallNotifyContent = {
|
const content: ICallNotifyContent = {
|
||||||
|
|
|
@ -19,7 +19,9 @@ import { Room, RoomMember } from "matrix-js-sdk/src/matrix";
|
||||||
import { getFunctionalMembers } from "./getFunctionalMembers";
|
import { getFunctionalMembers } from "./getFunctionalMembers";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all room members that are non-functional (bots etc.).
|
* 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 const getJoinedNonFunctionalMembers = (room: Room): RoomMember[] => {
|
export const getJoinedNonFunctionalMembers = (room: Room): RoomMember[] => {
|
||||||
const functionalMembers = getFunctionalMembers(room);
|
const functionalMembers = getFunctionalMembers(room);
|
||||||
|
|
|
@ -17,15 +17,7 @@ limitations under the License.
|
||||||
import EventEmitter from "events";
|
import EventEmitter from "events";
|
||||||
import { mocked } from "jest-mock";
|
import { mocked } from "jest-mock";
|
||||||
import { waitFor } from "@testing-library/react";
|
import { waitFor } from "@testing-library/react";
|
||||||
import {
|
import { RoomType, Room, RoomEvent, MatrixEvent, RoomStateEvent, PendingEventOrdering } from "matrix-js-sdk/src/matrix";
|
||||||
RoomType,
|
|
||||||
Room,
|
|
||||||
RoomEvent,
|
|
||||||
MatrixEvent,
|
|
||||||
RoomStateEvent,
|
|
||||||
PendingEventOrdering,
|
|
||||||
UNSTABLE_ELEMENT_FUNCTIONAL_USERS,
|
|
||||||
} from "matrix-js-sdk/src/matrix";
|
|
||||||
import { Widget } from "matrix-widget-api";
|
import { Widget } from "matrix-widget-api";
|
||||||
// eslint-disable-next-line no-restricted-imports
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import { MatrixRTCSessionManagerEvents } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSessionManager";
|
import { MatrixRTCSessionManagerEvents } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSessionManager";
|
||||||
|
@ -991,20 +983,11 @@ describe("ElementCall", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("create call", () => {
|
describe("create call", () => {
|
||||||
function setFunctionalMembers(members: string[]) {
|
function setRoomMembers(memberIds: string[]) {
|
||||||
room.currentState.setStateEvents([
|
jest.spyOn(room, "getJoinedMembers").mockReturnValue(memberIds.map((id) => ({ userId: id } as RoomMember)));
|
||||||
mkEvent({
|
|
||||||
event: true,
|
|
||||||
type: UNSTABLE_ELEMENT_FUNCTIONAL_USERS.name,
|
|
||||||
user: "@user:example.com",
|
|
||||||
room: room.roomId,
|
|
||||||
skey: "",
|
|
||||||
content: { service_members: members },
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
setFunctionalMembers(["@user:example.com", "@user2:example.com", "@user4:example.com"]);
|
setRoomMembers(["@user:example.com", "@user2:example.com", "@user4:example.com"]);
|
||||||
});
|
});
|
||||||
it("sends notify event on create in a room with more than two members", async () => {
|
it("sends notify event on create in a room with more than two members", async () => {
|
||||||
const sendEventSpy = jest.spyOn(room.client, "sendEvent");
|
const sendEventSpy = jest.spyOn(room.client, "sendEvent");
|
||||||
|
@ -1017,7 +1000,7 @@ describe("ElementCall", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("sends ring on create in a DM (two participants) room", async () => {
|
it("sends ring on create in a DM (two participants) room", async () => {
|
||||||
setFunctionalMembers(["@user:example.com", "@user2:example.com"]);
|
setRoomMembers(["@user:example.com", "@user2:example.com"]);
|
||||||
|
|
||||||
const sendEventSpy = jest.spyOn(room.client, "sendEvent");
|
const sendEventSpy = jest.spyOn(room.client, "sendEvent");
|
||||||
await ElementCall.create(room);
|
await ElementCall.create(room);
|
||||||
|
|
Loading…
Reference in New Issue