Fix room joining over federation not specifying vias or using aliases (#30641)
* Fix room joining over federation not specifying vias or using aliases Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Be consistent with viaServers Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Simplify modules Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Only consider canAskToJoin on 403 as per spec Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove unused helper which I only just added =( Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add test Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
committed by
GitHub
parent
1b4a979b6c
commit
8fa3d7e4b7
@@ -43,6 +43,7 @@ import { type IApp } from "../../../src/utils/WidgetUtils-types";
|
||||
import { CallStore } from "../../../src/stores/CallStore";
|
||||
import { MatrixClientPeg } from "../../../src/MatrixClientPeg";
|
||||
import MediaDeviceHandler, { MediaDeviceKindEnum } from "../../../src/MediaDeviceHandler";
|
||||
import { storeRoomAliasInCache } from "../../../src/RoomAliasCache.ts";
|
||||
|
||||
jest.mock("../../../src/Modal");
|
||||
|
||||
@@ -211,6 +212,22 @@ describe("RoomViewStore", function () {
|
||||
expect(roomViewStore.isJoining()).toBe(true);
|
||||
});
|
||||
|
||||
it("can be used to view a room by alias with auto_join", async () => {
|
||||
const alias = "#alias12345:server";
|
||||
storeRoomAliasInCache(alias, roomId, ["server1"]);
|
||||
dis.dispatch({ action: Action.ViewRoom, room_alias: alias, auto_join: true }, true);
|
||||
await expect(untilDispatch(Action.ViewRoom, dis)).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
action: Action.ViewRoom,
|
||||
room_id: roomId,
|
||||
auto_join: true,
|
||||
}),
|
||||
);
|
||||
await untilDispatch(Action.JoinRoomReady, dis);
|
||||
expect(mockClient.joinRoom).toHaveBeenCalledWith(alias, { viaServers: ["server1"] });
|
||||
expect(roomViewStore.isJoining()).toBe(true);
|
||||
});
|
||||
|
||||
it("can auto-join a room", async () => {
|
||||
dis.dispatch({ action: Action.ViewRoom, room_id: roomId, auto_join: true });
|
||||
await untilDispatch(Action.JoinRoomReady, dis);
|
||||
@@ -422,8 +439,8 @@ describe("RoomViewStore", function () {
|
||||
});
|
||||
|
||||
describe("Action.JoinRoom", () => {
|
||||
it("dispatches Action.JoinRoomError and Action.AskToJoin when the join fails", async () => {
|
||||
const err = new MatrixError();
|
||||
it("dispatches Action.JoinRoomError and Action.AskToJoin when the join fails with 403", async () => {
|
||||
const err = new MatrixError({}, 403);
|
||||
|
||||
jest.spyOn(dis, "dispatch");
|
||||
jest.spyOn(mockClient, "joinRoom").mockRejectedValueOnce(err);
|
||||
|
||||
Reference in New Issue
Block a user