summary refs log tree commit diff
path: root/synapse/util/msisdn.py
diff options
context:
space:
mode:
authorDavid Baker <dbkr@users.noreply.github.com>2025-05-05 10:08:50 +0100
committerGitHub <noreply@github.com>2025-05-05 11:08:50 +0200
commit9f9eb563339079ee5ce082fcd63d0ab5d849b7ed (patch)
tree6ebf7e94aa718ce4482b5d1c87ff764d101fbab6 /synapse/util/msisdn.py
parentAdd the ability to exclude remote users in user directory search results (#18... (diff)
downloadsynapse-9f9eb563339079ee5ce082fcd63d0ab5d849b7ed.tar.xz
Return specific error code when email / phone not supported (#17578)
Implements https://github.com/matrix-org/matrix-spec-proposals/pull/4178

If this would need tests, could you give some idea of what tests would
be needed and how best to add them?

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [ ] Pull request is based on the develop branch
* [ ] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [ ] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct
(run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
Diffstat (limited to 'synapse/util/msisdn.py')
-rw-r--r--synapse/util/msisdn.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/synapse/util/msisdn.py b/synapse/util/msisdn.py

index b6a784f0bc..dce8da5e18 100644 --- a/synapse/util/msisdn.py +++ b/synapse/util/msisdn.py
@@ -21,7 +21,7 @@ import phonenumbers -from synapse.api.errors import SynapseError +from synapse.api.errors import Codes, SynapseError def phone_number_to_msisdn(country: str, number: str) -> str: @@ -45,7 +45,7 @@ def phone_number_to_msisdn(country: str, number: str) -> str: try: phoneNumber = phonenumbers.parse(number, country) except phonenumbers.NumberParseException: - raise SynapseError(400, "Unable to parse phone number") + raise SynapseError(400, "Unable to parse phone number", Codes.INVALID_PARAM) return phonenumbers.format_number(phoneNumber, phonenumbers.PhoneNumberFormat.E164)[ 1: ]