Remove unknown MXIDs from invite suggestions (#11055)
This commit is contained in:
parent
d381fa3f2c
commit
386a459b9f
2 changed files with 5 additions and 21 deletions
|
@ -26,12 +26,7 @@ import { Icon as InfoIcon } from "../../../../res/img/element-icons/info.svg";
|
||||||
import { Icon as EmailPillAvatarIcon } from "../../../../res/img/icon-email-pill-avatar.svg";
|
import { Icon as EmailPillAvatarIcon } from "../../../../res/img/icon-email-pill-avatar.svg";
|
||||||
import { _t, _td } from "../../../languageHandler";
|
import { _t, _td } from "../../../languageHandler";
|
||||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||||
import {
|
import { makeRoomPermalink, makeUserPermalink } from "../../../utils/permalinks/Permalinks";
|
||||||
getHostnameFromMatrixServerName,
|
|
||||||
getServerName,
|
|
||||||
makeRoomPermalink,
|
|
||||||
makeUserPermalink,
|
|
||||||
} from "../../../utils/permalinks/Permalinks";
|
|
||||||
import DMRoomMap from "../../../utils/DMRoomMap";
|
import DMRoomMap from "../../../utils/DMRoomMap";
|
||||||
import SdkConfig from "../../../SdkConfig";
|
import SdkConfig from "../../../SdkConfig";
|
||||||
import * as Email from "../../../email";
|
import * as Email from "../../../email";
|
||||||
|
@ -724,18 +719,6 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn("Non-fatal error trying to make an invite for a user ID", e);
|
logger.warn("Non-fatal error trying to make an invite for a user ID", e);
|
||||||
|
|
||||||
// Reuse logic from Permalinks as a basic MXID validity check
|
|
||||||
const serverName = getServerName(term);
|
|
||||||
const domain = getHostnameFromMatrixServerName(serverName);
|
|
||||||
if (domain) {
|
|
||||||
// Add a result anyways, just without a profile. We stick it at the
|
|
||||||
// top so it is most obviously presented to the user.
|
|
||||||
r.results.splice(0, 0, {
|
|
||||||
user_id: term,
|
|
||||||
display_name: term,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import InviteDialog from "../../../../src/components/views/dialogs/InviteDialog"
|
||||||
import { InviteKind } from "../../../../src/components/views/dialogs/InviteDialogTypes";
|
import { InviteKind } from "../../../../src/components/views/dialogs/InviteDialogTypes";
|
||||||
import {
|
import {
|
||||||
filterConsole,
|
filterConsole,
|
||||||
|
flushPromises,
|
||||||
getMockClientWithEventEmitter,
|
getMockClientWithEventEmitter,
|
||||||
mkMembership,
|
mkMembership,
|
||||||
mkMessage,
|
mkMessage,
|
||||||
|
@ -200,7 +201,7 @@ describe("InviteDialog", () => {
|
||||||
expect(screen.getByText(`Invite to ${roomId}`)).toBeInTheDocument();
|
expect(screen.getByText(`Invite to ${roomId}`)).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should suggest valid MXIDs even if unknown", async () => {
|
it("should not suggest valid unknown MXIDs", async () => {
|
||||||
render(
|
render(
|
||||||
<InviteDialog
|
<InviteDialog
|
||||||
kind={InviteKind.Invite}
|
kind={InviteKind.Invite}
|
||||||
|
@ -209,8 +210,8 @@ describe("InviteDialog", () => {
|
||||||
initialText="@localpart:server.tld"
|
initialText="@localpart:server.tld"
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
await flushPromises();
|
||||||
await screen.findAllByText("@localpart:server.tld"); // Using findAllByText as the MXID is used for name too
|
expect(screen.queryByText("@localpart:server.tld")).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not suggest invalid MXIDs", () => {
|
it("should not suggest invalid MXIDs", () => {
|
||||||
|
|
Loading…
Reference in a new issue