Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add better error for email invites without identity server #10739

Merged
merged 4 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@
"The user must be unbanned before they can be invited.": "The user must be unbanned before they can be invited.",
"The user's homeserver does not support the version of the space.": "The user's homeserver does not support the version of the space.",
"The user's homeserver does not support the version of the room.": "The user's homeserver does not support the version of the room.",
"Cannot invite user by email without an identity server. You can connect to one under \"Settings\".": "Cannot invite user by email without an identity server. You can connect to one under \"Settings\".",
"Unknown server error": "Unknown server error",
"Use a few words, avoid common phrases": "Use a few words, avoid common phrases",
"No need for symbols, digits, or uppercase letters": "No need for symbols, digits, or uppercase letters",
Expand Down
7 changes: 7 additions & 0 deletions src/utils/MultiInviter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@ export default class MultiInviter {
errorText = _t("The user's homeserver does not support the version of the room.");
}
break;
case "ORG.MATRIX.JSSDK_MISSING_PARAM":
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
if (getAddressType(address) === AddressType.Email) {
errorText = _t(
"Cannot invite user by email without an identity server. " +
'You can connect to one under "Settings".',
);
}
}

if (!errorText) {
Expand Down
14 changes: 13 additions & 1 deletion test/utils/MultiInviter-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { mocked } from "jest-mock";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { MatrixClient, MatrixError } from "matrix-js-sdk/src/matrix";

import { MatrixClientPeg } from "../../src/MatrixClientPeg";
import Modal, { ComponentType, ComponentProps } from "../../src/Modal";
Expand Down Expand Up @@ -142,5 +142,17 @@ describe("MultiInviter", () => {
});
});
});

it("should show sensible error when attempting 3pid invite with no identity server", async () => {
client.inviteByEmail = jest.fn().mockRejectedValueOnce(
new MatrixError({
errcode: "ORG.MATRIX.JSSDK_MISSING_PARAM",
}),
);
await inviter.invite(["[email protected]"]);
expect(inviter.getErrorText("[email protected]")).toMatchInlineSnapshot(
`"Cannot invite user by email without an identity server. You can connect to one under "Settings"."`,
);
});
});
});