Support error code for email / phone adding unsupported (#29855)
https://github.com/matrix-org/matrix-spec-proposals/pull/4178
This commit is contained in:
@@ -79,6 +79,8 @@ export default class AddThreepid {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof MatrixError && err.errcode === "M_THREEPID_IN_USE") {
|
if (err instanceof MatrixError && err.errcode === "M_THREEPID_IN_USE") {
|
||||||
throw new UserFriendlyError("settings|general|email_address_in_use", { cause: err });
|
throw new UserFriendlyError("settings|general|email_address_in_use", { cause: err });
|
||||||
|
} else if (err instanceof MatrixError && err.errcode === "M_THREEPID_MEDIUM_NOT_SUPPORTED") {
|
||||||
|
throw new UserFriendlyError("settings|general|email_adding_unsupported_by_hs", { cause: err });
|
||||||
}
|
}
|
||||||
// Otherwise, just blurt out the same error
|
// Otherwise, just blurt out the same error
|
||||||
throw err;
|
throw err;
|
||||||
@@ -121,6 +123,8 @@ export default class AddThreepid {
|
|||||||
* @param {string} phoneCountry The ISO 2 letter code of the country to resolve phoneNumber in
|
* @param {string} phoneCountry The ISO 2 letter code of the country to resolve phoneNumber in
|
||||||
* @param {string} phoneNumber The national or international formatted phone number to add
|
* @param {string} phoneNumber The national or international formatted phone number to add
|
||||||
* @return {Promise} Resolves when the text message has been sent. Then call haveMsisdnToken().
|
* @return {Promise} Resolves when the text message has been sent. Then call haveMsisdnToken().
|
||||||
|
*
|
||||||
|
* @throws {UserFriendlyError} An appropriate user-friendly error if the verification code could not be sent.
|
||||||
*/
|
*/
|
||||||
public async addMsisdn(phoneCountry: string, phoneNumber: string): Promise<IRequestMsisdnTokenResponse> {
|
public async addMsisdn(phoneCountry: string, phoneNumber: string): Promise<IRequestMsisdnTokenResponse> {
|
||||||
try {
|
try {
|
||||||
@@ -136,6 +140,10 @@ export default class AddThreepid {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof MatrixError && err.errcode === "M_THREEPID_IN_USE") {
|
if (err instanceof MatrixError && err.errcode === "M_THREEPID_IN_USE") {
|
||||||
throw new UserFriendlyError("settings|general|msisdn_in_use", { cause: err });
|
throw new UserFriendlyError("settings|general|msisdn_in_use", { cause: err });
|
||||||
|
} else if (err instanceof MatrixError && err.errcode === "M_THREEPID_MEDIUM_NOT_SUPPORTED") {
|
||||||
|
throw new UserFriendlyError("settings|general|msisdn_adding_unsupported_by_hs", { cause: err });
|
||||||
|
} else if (err instanceof MatrixError && err.errcode === "M_INVALID_PARAM") {
|
||||||
|
throw new UserFriendlyError("settings|general|invalid_phone_number", { cause: err });
|
||||||
}
|
}
|
||||||
// Otherwise, just blurt out the same error
|
// Otherwise, just blurt out the same error
|
||||||
throw err;
|
throw err;
|
||||||
|
|||||||
@@ -2634,6 +2634,7 @@
|
|||||||
"discovery_needs_terms_title": "Let people find you",
|
"discovery_needs_terms_title": "Let people find you",
|
||||||
"display_name": "Display Name",
|
"display_name": "Display Name",
|
||||||
"display_name_error": "Unable to set display name",
|
"display_name_error": "Unable to set display name",
|
||||||
|
"email_adding_unsupported_by_hs": "This homeserver does not support adding email addresses to your account.",
|
||||||
"email_address_in_use": "This email address is already in use",
|
"email_address_in_use": "This email address is already in use",
|
||||||
"email_address_label": "Email Address",
|
"email_address_label": "Email Address",
|
||||||
"email_not_verified": "Your email address hasn't been verified yet",
|
"email_not_verified": "Your email address hasn't been verified yet",
|
||||||
@@ -2658,7 +2659,9 @@
|
|||||||
"error_share_msisdn_discovery": "Unable to share phone number",
|
"error_share_msisdn_discovery": "Unable to share phone number",
|
||||||
"identity_server_no_token": "No identity access token found",
|
"identity_server_no_token": "No identity access token found",
|
||||||
"identity_server_not_set": "Identity server not set",
|
"identity_server_not_set": "Identity server not set",
|
||||||
|
"invalid_phone_number": "The phone number supplied does not appear to be valid.",
|
||||||
"language_section": "Language",
|
"language_section": "Language",
|
||||||
|
"msisdn_adding_unsupported_by_hs": "This homeserver does not support adding phone numbers to your account.",
|
||||||
"msisdn_in_use": "This phone number is already in use",
|
"msisdn_in_use": "This phone number is already in use",
|
||||||
"msisdn_label": "Phone Number",
|
"msisdn_label": "Phone Number",
|
||||||
"msisdn_verification_field_label": "Verification code",
|
"msisdn_verification_field_label": "Verification code",
|
||||||
|
|||||||
Reference in New Issue
Block a user