From 037d93471d857669b5aad4588370a2fcf65f1310 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 30 May 2022 22:18:28 +0300 Subject: [PATCH] Catch PhoneNumberUnoccupied in /login/send_code provisioning API --- mautrix_telegram/web/common/auth_api.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mautrix_telegram/web/common/auth_api.py b/mautrix_telegram/web/common/auth_api.py index e8cd0833..4089cc23 100644 --- a/mautrix_telegram/web/common/auth_api.py +++ b/mautrix_telegram/web/common/auth_api.py @@ -279,6 +279,14 @@ class AuthAPI(abc.ABC): errcode="phone_code_expired", error="Phone code expired.", ) + except PhoneNumberUnoccupiedError: + return self.get_login_response( + mxid=user.mxid, + state="code", + status=403, + errcode="phone_number_unoccupied", + error="That phone number has not been registered.", + ) except SessionPasswordNeededError: if not password_in_data: if user.command_status and user.command_status["action"] == "Login":