Fix external guest access url for unencrypted rooms (#12345)
* use unencrypted calls in unencrypted rooms (make external call links compatible with unencrypted embedded calls) Signed-off-by: Timo K <toger5@hotmail.de> * use same logic in Call.ts Signed-off-by: Timo K <toger5@hotmail.de> * fix tests Signed-off-by: Timo K <toger5@hotmail.de> * fix test Signed-off-by: Timo K <toger5@hotmail.de> --------- Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
parent
75a989e409
commit
09f0d11e7f
5 changed files with 24 additions and 6 deletions
|
@ -282,7 +282,7 @@ export const useRoomCall = (
|
||||||
url.pathname = "/room/";
|
url.pathname = "/room/";
|
||||||
// Set params for the sharable url
|
// Set params for the sharable url
|
||||||
url.searchParams.set("roomId", room.roomId);
|
url.searchParams.set("roomId", room.roomId);
|
||||||
url.searchParams.set("perParticipantE2EE", "true");
|
if (room.hasEncryptionStateEvent()) url.searchParams.set("perParticipantE2EE", "true");
|
||||||
for (const server of calculateRoomVia(room)) {
|
for (const server of calculateRoomVia(room)) {
|
||||||
url.searchParams.set("viaServers", server);
|
url.searchParams.set("viaServers", server);
|
||||||
}
|
}
|
||||||
|
|
|
@ -778,7 +778,10 @@ export class ElementCall extends Call {
|
||||||
overwriteData: IWidgetData,
|
overwriteData: IWidgetData,
|
||||||
): IWidgetData {
|
): IWidgetData {
|
||||||
let perParticipantE2EE = false;
|
let perParticipantE2EE = false;
|
||||||
if (client.isRoomEncrypted(roomId) && !SettingsStore.getValue("feature_disable_call_per_sender_encryption"))
|
if (
|
||||||
|
client.getRoom(roomId)?.hasEncryptionStateEvent() &&
|
||||||
|
!SettingsStore.getValue("feature_disable_call_per_sender_encryption")
|
||||||
|
)
|
||||||
perParticipantE2EE = true;
|
perParticipantE2EE = true;
|
||||||
return {
|
return {
|
||||||
...currentData,
|
...currentData,
|
||||||
|
|
|
@ -563,9 +563,10 @@ describe("RoomHeader", () => {
|
||||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||||
expect(getByLabelText(container, _t("voip|get_call_link"))).toBeInTheDocument();
|
expect(getByLabelText(container, _t("voip|get_call_link"))).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
it("opens the share dialog with the correct share link", () => {
|
it("opens the share dialog with the correct share link in an encrypted room", () => {
|
||||||
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Public);
|
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Public);
|
||||||
jest.spyOn(SdkContextClass.instance.roomViewStore, "isViewingCall").mockReturnValue(true);
|
jest.spyOn(SdkContextClass.instance.roomViewStore, "isViewingCall").mockReturnValue(true);
|
||||||
|
jest.spyOn(room, "hasEncryptionStateEvent").mockReturnValue(true);
|
||||||
|
|
||||||
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||||
const modalSpy = jest.spyOn(Modal, "createDialog");
|
const modalSpy = jest.spyOn(Modal, "createDialog");
|
||||||
|
@ -583,6 +584,20 @@ describe("RoomHeader", () => {
|
||||||
});
|
});
|
||||||
expect(arg1.target.toString()).toEqual(target);
|
expect(arg1.target.toString()).toEqual(target);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("share dialog has correct link in an unencrypted room", () => {
|
||||||
|
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Public);
|
||||||
|
jest.spyOn(room, "hasEncryptionStateEvent").mockReturnValue(false);
|
||||||
|
jest.spyOn(SdkContextClass.instance.roomViewStore, "isViewingCall").mockReturnValue(true);
|
||||||
|
|
||||||
|
const { container } = render(<RoomHeader room={room} />, getWrapper());
|
||||||
|
const modalSpy = jest.spyOn(Modal, "createDialog");
|
||||||
|
fireEvent.click(getByLabelText(container, _t("voip|get_call_link")));
|
||||||
|
const target =
|
||||||
|
"https://guest_spa_url.com/room/#/!1:example.org?roomId=%211%3Aexample.org&viaServers=example.org";
|
||||||
|
const arg1 = modalSpy.mock.calls[0][1] as any;
|
||||||
|
expect(arg1.target.toString()).toEqual(target);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("public room", () => {
|
describe("public room", () => {
|
||||||
|
|
|
@ -1039,7 +1039,7 @@ describe("ElementCall", () => {
|
||||||
call.destroy();
|
call.destroy();
|
||||||
const addWidgetSpy = jest.spyOn(WidgetStore.instance, "addVirtualWidget");
|
const addWidgetSpy = jest.spyOn(WidgetStore.instance, "addVirtualWidget");
|
||||||
// If a room is not encrypted we will never add the perParticipantE2EE flag.
|
// If a room is not encrypted we will never add the perParticipantE2EE flag.
|
||||||
client.isRoomEncrypted.mockReturnValue(true);
|
const roomSpy = jest.spyOn(room, "hasEncryptionStateEvent").mockReturnValue(true);
|
||||||
|
|
||||||
// should create call with perParticipantE2EE flag
|
// should create call with perParticipantE2EE flag
|
||||||
ElementCall.create(room);
|
ElementCall.create(room);
|
||||||
|
@ -1049,8 +1049,7 @@ describe("ElementCall", () => {
|
||||||
enabledSettings.add("feature_disable_call_per_sender_encryption");
|
enabledSettings.add("feature_disable_call_per_sender_encryption");
|
||||||
expect(Call.get(room)?.widget?.data?.perParticipantE2EE).toBe(false);
|
expect(Call.get(room)?.widget?.data?.perParticipantE2EE).toBe(false);
|
||||||
enabledSettings.delete("feature_disable_call_per_sender_encryption");
|
enabledSettings.delete("feature_disable_call_per_sender_encryption");
|
||||||
|
roomSpy.mockRestore();
|
||||||
client.isRoomEncrypted.mockClear();
|
|
||||||
addWidgetSpy.mockRestore();
|
addWidgetSpy.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -624,6 +624,7 @@ export function mkStubRoom(
|
||||||
isElementVideoRoom: jest.fn().mockReturnValue(false),
|
isElementVideoRoom: jest.fn().mockReturnValue(false),
|
||||||
isSpaceRoom: jest.fn().mockReturnValue(false),
|
isSpaceRoom: jest.fn().mockReturnValue(false),
|
||||||
isCallRoom: jest.fn().mockReturnValue(false),
|
isCallRoom: jest.fn().mockReturnValue(false),
|
||||||
|
hasEncryptionStateEvent: jest.fn().mockReturnValue(false),
|
||||||
loadMembersIfNeeded: jest.fn(),
|
loadMembersIfNeeded: jest.fn(),
|
||||||
maySendMessage: jest.fn().mockReturnValue(true),
|
maySendMessage: jest.fn().mockReturnValue(true),
|
||||||
myUserId: client?.getUserId(),
|
myUserId: client?.getUserId(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue