diff --git a/td/mtproto/PingConnection.cpp b/td/mtproto/PingConnection.cpp index 92945ea39..494b2d05d 100644 --- a/td/mtproto/PingConnection.cpp +++ b/td/mtproto/PingConnection.cpp @@ -146,7 +146,7 @@ class PingConnectionPingPong final LOG(ERROR) << "Unexpected message"; return Status::OK(); } - void on_message_result_error(uint64 id, int code, BufferSlice descr) final { + void on_message_result_error(uint64 id, int code, string message) final { } void on_message_failed(uint64 id, Status status) final { } diff --git a/td/mtproto/SessionConnection.cpp b/td/mtproto/SessionConnection.cpp index 7e9409b2f..f875b1ad4 100644 --- a/td/mtproto/SessionConnection.cpp +++ b/td/mtproto/SessionConnection.cpp @@ -302,7 +302,7 @@ Status SessionConnection::on_packet(const MsgInfo &info, uint64 req_msg_id, cons VLOG(mtproto) << "ERROR " << tag("code", rpc_error.error_code_) << tag("message", rpc_error.error_message_) << tag("req_msg_id", req_msg_id); if (req_msg_id != 0) { - callback_->on_message_result_error(req_msg_id, rpc_error.error_code_, as_buffer_slice(rpc_error.error_message_)); + callback_->on_message_result_error(req_msg_id, rpc_error.error_code_, rpc_error.error_message_.str()); } else { LOG(WARNING) << "Receive rpc_error as update: [" << rpc_error.error_code_ << "][" << rpc_error.error_message_ << "]"; diff --git a/td/mtproto/SessionConnection.h b/td/mtproto/SessionConnection.h index bb43dd25f..24bc82103 100644 --- a/td/mtproto/SessionConnection.h +++ b/td/mtproto/SessionConnection.h @@ -111,7 +111,7 @@ class SessionConnection final virtual void on_message_ack(uint64 id) = 0; virtual Status on_message_result_ok(uint64 id, BufferSlice packet, size_t original_size) = 0; - virtual void on_message_result_error(uint64 id, int code, BufferSlice descr) = 0; + virtual void on_message_result_error(uint64 id, int code, string message) = 0; virtual void on_message_failed(uint64 id, Status status) = 0; virtual void on_message_info(uint64 id, int32 state, uint64 answer_id, int32 answer_size) = 0; diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index 2a7bef7b5..4b0297e9b 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -768,22 +768,22 @@ Status Session::on_message_result_ok(uint64 id, BufferSlice packet, size_t origi return Status::OK(); } -void Session::on_message_result_error(uint64 id, int error_code, BufferSlice message) { +void Session::on_message_result_error(uint64 id, int error_code, string message) { // UNAUTHORIZED - if (error_code == 401 && message.as_slice() != CSlice("SESSION_PASSWORD_NEEDED")) { - if (auth_data_.use_pfs() && message.as_slice() == CSlice("AUTH_KEY_PERM_EMPTY")) { + if (error_code == 401 && message != CSlice("SESSION_PASSWORD_NEEDED")) { + if (auth_data_.use_pfs() && message == CSlice("AUTH_KEY_PERM_EMPTY")) { 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 { - if (message.as_slice() == CSlice("USER_DEACTIVATED_BAN")) { + if (message == 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."; } auth_data_.set_auth_flag(false); - G()->shared_config().set_option_string("auth", message.as_slice().str()); + G()->shared_config().set_option_string("auth", message); shared_auth_data_->set_auth_key(auth_data_.get_main_auth_key()); on_session_failed(Status::OK()); } @@ -796,10 +796,10 @@ void Session::on_message_result_error(uint64 id, int error_code, BufferSlice mes if (error_code < 0) { LOG(WARNING) << "Session::on_message_result_error from mtproto " << tag("id", id) << tag("error_code", error_code) - << tag("msg", message.as_slice()); + << tag("msg", message); } else { LOG(DEBUG) << "Session::on_message_result_error " << tag("id", id) << tag("error_code", error_code) - << tag("msg", message.as_slice()); + << tag("msg", message); } auto it = sent_queries_.find(id); if (it == sent_queries_.end()) { @@ -811,8 +811,7 @@ void Session::on_message_result_error(uint64 id, int error_code, BufferSlice mes cleanup_container(id, query_ptr); mark_as_known(id, query_ptr); - query_ptr->query->set_error(Status::Error(error_code, message.as_slice()), - current_info_->connection->get_name().str()); + query_ptr->query->set_error(Status::Error(error_code, message), current_info_->connection->get_name().str()); query_ptr->query->set_message_id(0); query_ptr->query->cancel_slot_.clear_event(); return_query(std::move(query_ptr->query)); diff --git a/td/telegram/net/Session.h b/td/telegram/net/Session.h index 32776fd6d..022aafff4 100644 --- a/td/telegram/net/Session.h +++ b/td/telegram/net/Session.h @@ -208,7 +208,7 @@ class Session final void on_message_ack(uint64 id) final; Status on_message_result_ok(uint64 id, BufferSlice packet, size_t original_size) final; - void on_message_result_error(uint64 id, int error_code, BufferSlice message) final; + void on_message_result_error(uint64 id, int error_code, string message) final; void on_message_failed(uint64 id, Status status) final; void on_message_info(uint64 id, int32 state, uint64 answer_id, int32 answer_size) final;