From c72ba02d85ae63313a4b40ebda58a1e7505e532d Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 2 Sep 2019 19:24:50 +0300 Subject: [PATCH] Write to the log message when account is banned. GitOrigin-RevId: 087777440601fc56f9289fc8140497a1553755db --- td/telegram/AuthManager.cpp | 4 ++++ td/telegram/net/Session.cpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/td/telegram/AuthManager.cpp b/td/telegram/AuthManager.cpp index 8afbea10..4f73cef5 100644 --- a/td/telegram/AuthManager.cpp +++ b/td/telegram/AuthManager.cpp @@ -381,6 +381,10 @@ void AuthManager::start_net_query(NetQueryType net_query_type, NetQueryPtr net_q void AuthManager::on_send_code_result(NetQueryPtr &result) { auto r_sent_code = fetch_result(result->ok()); if (r_sent_code.is_error()) { + if (r_sent_code.error().message() == CSlice("PHONE_NUMBER_BANNED")) { + LOG(PLAIN) << "Your phone number was banned for suspicious activity. If you think that this is a mistake, please " + "write to recover@telegram.org your phone number and other details to recover the account."; + } return on_query_error(r_sent_code.move_as_error()); } auto sent_code = r_sent_code.move_as_ok(); diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index 9e461b1d..6c9fde10 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -660,16 +660,20 @@ Status Session::on_message_result_ok(uint64 id, BufferSlice packet, size_t origi void Session::on_message_result_error(uint64 id, int error_code, BufferSlice message) { // UNAUTHORIZED - // TODO: some errors shouldn't cause loss of authorizations. Especially when PFS will be used if (error_code == 401 && message.as_slice() != CSlice("SESSION_PASSWORD_NEEDED")) { if (auth_data_.use_pfs() && message.as_slice() == CSlice("AUTH_KEY_PERM_EMPTY")) { - LOG(ERROR) << "Receive AUTH_KEY_PERM_EMPTY in session " << auth_data_.get_session_id() << " for auth key " - << auth_data_.get_tmp_auth_key().id(); + LOG(INFO) << "Receive AUTH_KEY_PERM_EMPTY in session " << auth_data_.get_session_id() << " for auth key " + << auth_data_.get_tmp_auth_key().id(); auth_data_.drop_tmp_auth_key(); on_tmp_auth_key_updated(); error_code = 500; } else { - LOG(WARNING) << "Lost authorization due to " << tag("msg", message.as_slice()); + if (message.as_slice() == CSlice("USER_DEACTIVATED_BAN")) { + LOG(PLAIN) << "Your account was suspended for suspicious activity. If you think that this is a mistake, please " + "write to recover@telegram.org your phone number and other details to recover the account."; + } else { + LOG(WARNING) << "Lost authorization due to " << tag("msg", message.as_slice()); + } auth_data_.set_auth_flag(false); shared_auth_data_->set_auth_key(auth_data_.get_main_auth_key()); on_session_failed(Status::OK());