diff --git a/td/telegram/AuthManager.cpp b/td/telegram/AuthManager.cpp index 9d7a23a56..38a414f51 100644 --- a/td/telegram/AuthManager.cpp +++ b/td/telegram/AuthManager.cpp @@ -1141,6 +1141,16 @@ void AuthManager::on_log_out_result(NetQueryPtr &&net_query) { destroy_auth_keys(); on_current_query_ok(); } + +void AuthManager::on_account_banned() const { + if (is_bot()) { + return; + } + LOG(ERROR) << "Your account was banned for suspicious activity. If you think that this is a mistake, please try to " + "log in from an official mobile app and send a email to recover the account by following instructions " + "provided by the app"; +} + void AuthManager::on_authorization_lost(string source) { if (state_ == State::LoggingOut && net_query_type_ == NetQueryType::LogOut) { LOG(INFO) << "Ignore authorization loss because of " << source << ", while logging out"; @@ -1151,6 +1161,9 @@ void AuthManager::on_authorization_lost(string source) { return; } LOG(WARNING) << "Lost authorization because of " << source; + if (source == "USER_DEACTIVATED_BAN") { + on_account_banned(); + } destroy_auth_keys(); } @@ -1290,9 +1303,7 @@ void AuthManager::on_result(NetQueryPtr net_query) { return; } if (net_query->error().message() == CSlice("PHONE_NUMBER_BANNED")) { - LOG(ERROR) << "Your phone number was banned for suspicious activity. If you think that this is a mistake, " - "please try to log in from an official mobile app and send a email to recover the account by " - "following instructions provided by the app."; + on_account_banned(); } if (type != NetQueryType::LogOut && type != NetQueryType::DeleteAccount) { if (query_id_ != 0) { diff --git a/td/telegram/AuthManager.h b/td/telegram/AuthManager.h index d525cc4a1..1aaa00c4f 100644 --- a/td/telegram/AuthManager.h +++ b/td/telegram/AuthManager.h @@ -196,6 +196,8 @@ class AuthManager final : public NetActor { void send_log_out_query(); void destroy_auth_keys(); + void on_account_banned() const; + void on_sent_code(telegram_api::object_ptr &&sent_code_ptr); void on_send_code_result(NetQueryPtr &&net_query); diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index a07b51725..38a31973b 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -957,11 +957,6 @@ void Session::on_message_result_error(uint64 message_id, int error_code, string on_auth_key_updated(); error_code = 500; } else { - if (message == "USER_DEACTIVATED_BAN") { - LOG(ERROR) << "Your phone number was banned for suspicious activity. If you think that this is a mistake, " - "please try to log in from an official mobile app and send a email to recover the account by " - "following instructions provided by the app."; - } auth_data_.set_auth_flag(false); G()->log_out(message); shared_auth_data_->set_auth_key(auth_data_.get_main_auth_key());