InviteDialog: remove broken checks for unknown users (#33026)

* InviteDialog: remove broken checks for unknown users

Per https://github.com/element-hq/element-web/issues/33020, this doesn't
actually work, and if we were to bring it back, we'd design it differently.

* Remove now-unused `UserProfilesStore.getProfileLookupError`

This was only used in `InviteDialog.checkProfileAndStartDm`, which has now been
removed.
This commit is contained in:
Richard van der Hoff
2026-04-02 15:31:29 +00:00
committed by GitHub
parent d7a5659180
commit 5e140768f0
5 changed files with 3 additions and 163 deletions
@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
*/
import React, { createRef, type JSX, type ReactNode, type SyntheticEvent } from "react";
import { EventType, MatrixError, type Room, RoomMember } from "matrix-js-sdk/src/matrix";
import { EventType, type Room, RoomMember } from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
import { type MatrixCall } from "matrix-js-sdk/src/webrtc/call";
import { logger } from "matrix-js-sdk/src/logger";
@@ -60,8 +60,6 @@ import Modal from "../../../Modal";
import dis from "../../../dispatcher/dispatcher";
import { privateShouldBeEncrypted } from "../../../utils/rooms";
import { type NonEmptyArray } from "../../../@types/common";
import { UNKNOWN_PROFILE_ERRORS } from "../../../utils/MultiInviter";
import AskInviteAnywayDialog, { type UnknownProfiles } from "./AskInviteAnywayDialog";
import { SdkContextClass } from "../../../contexts/SDKContext";
import { type UserProfilesStore } from "../../../stores/UserProfilesStore";
import InviteProgressBody from "./InviteProgressBody.tsx";
@@ -69,30 +67,6 @@ import InviteProgressBody from "./InviteProgressBody.tsx";
// we have a number of types defined from the Matrix spec which can't reasonably be altered here.
/* eslint-disable camelcase */
const extractTargetUnknownProfiles = async (
targets: Member[],
profilesStores: UserProfilesStore,
): Promise<UnknownProfiles> => {
const directoryMembers = targets.filter((t): t is DirectoryMember => t instanceof DirectoryMember);
await Promise.all(directoryMembers.map((t) => profilesStores.getOrFetchProfile(t.userId)));
return directoryMembers.reduce<UnknownProfiles>((unknownProfiles: UnknownProfiles, target: DirectoryMember) => {
const lookupError = profilesStores.getProfileLookupError(target.userId);
if (
lookupError instanceof MatrixError &&
lookupError.errcode &&
UNKNOWN_PROFILE_ERRORS.includes(lookupError.errcode)
) {
unknownProfiles.push({
userId: target.userId,
errorText: lookupError.data.error || "",
});
}
return unknownProfiles;
}, []);
};
interface Result {
userId: string;
user: Member;
@@ -467,26 +441,6 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
return newTargets;
}
/**
* Check if there are unknown profiles if promptBeforeInviteUnknownUsers setting is enabled.
* If so show the "invite anyway?" dialog. Otherwise directly create the DM local room.
*/
private checkProfileAndStartDm = async (): Promise<void> => {
this.setBusy(true);
const targets = this.convertFilter();
if (SettingsStore.getValue("promptBeforeInviteUnknownUsers")) {
const unknownProfileUsers = await extractTargetUnknownProfiles(targets, this.profilesStore);
if (unknownProfileUsers.length) {
this.showAskInviteAnywayDialog(unknownProfileUsers);
return;
}
}
await this.startDm();
};
private startDm = async (): Promise<void> => {
this.setBusy(true);
@@ -510,19 +464,6 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
});
}
private showAskInviteAnywayDialog(unknownProfileUsers: { userId: string; errorText: string }[]): void {
Modal.createDialog(AskInviteAnywayDialog, {
unknownProfileUsers,
onInviteAnyways: () => this.startDm(),
onGiveUp: () => {
this.setBusy(false);
},
description: _t("invite|ask_anyway_description"),
inviteNeverWarnLabel: _t("invite|ask_anyway_never_warn_label"),
inviteLabel: _t("invite|ask_anyway_label"),
});
}
private inviteUsers = async (): Promise<void> => {
if (this.props.kind !== InviteKind.Invite) return;
this.setState({ busy: true });
@@ -1283,7 +1224,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
}
buttonText = _t("action|go");
goButtonFn = this.checkProfileAndStartDm;
goButtonFn = this.startDm;
} else if (this.props.kind === InviteKind.Invite) {
const roomId = this.props.roomId;
const room = MatrixClientPeg.get()?.getRoom(roomId);