diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index c6c0a65ad8a..277da44a9c4 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -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", diff --git a/src/utils/MultiInviter.ts b/src/utils/MultiInviter.ts index 02cbbe585ba..a4c2657140b 100644 --- a/src/utils/MultiInviter.ts +++ b/src/utils/MultiInviter.ts @@ -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": + 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) { diff --git a/test/utils/MultiInviter-test.ts b/test/utils/MultiInviter-test.ts index b6091e59080..d9f4a9bf445 100644 --- a/test/utils/MultiInviter-test.ts +++ b/test/utils/MultiInviter-test.ts @@ -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"; @@ -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(["foo@bar.com"]); + expect(inviter.getErrorText("foo@bar.com")).toMatchInlineSnapshot( + `"Cannot invite user by email without an identity server. You can connect to one under "Settings"."`, + ); + }); }); });