Pass error message as string.
This commit is contained in:
parent
f327ff1cfd
commit
40cb97841a
|
@ -146,7 +146,7 @@ class PingConnectionPingPong final
|
||||||
LOG(ERROR) << "Unexpected message";
|
LOG(ERROR) << "Unexpected message";
|
||||||
return Status::OK();
|
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 {
|
void on_message_failed(uint64 id, Status status) final {
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_)
|
VLOG(mtproto) << "ERROR " << tag("code", rpc_error.error_code_) << tag("message", rpc_error.error_message_)
|
||||||
<< tag("req_msg_id", req_msg_id);
|
<< tag("req_msg_id", req_msg_id);
|
||||||
if (req_msg_id != 0) {
|
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 {
|
} else {
|
||||||
LOG(WARNING) << "Receive rpc_error as update: [" << rpc_error.error_code_ << "][" << rpc_error.error_message_
|
LOG(WARNING) << "Receive rpc_error as update: [" << rpc_error.error_code_ << "][" << rpc_error.error_message_
|
||||||
<< "]";
|
<< "]";
|
||||||
|
|
|
@ -111,7 +111,7 @@ class SessionConnection final
|
||||||
|
|
||||||
virtual void on_message_ack(uint64 id) = 0;
|
virtual void on_message_ack(uint64 id) = 0;
|
||||||
virtual Status on_message_result_ok(uint64 id, BufferSlice packet, size_t original_size) = 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_failed(uint64 id, Status status) = 0;
|
||||||
virtual void on_message_info(uint64 id, int32 state, uint64 answer_id, int32 answer_size) = 0;
|
virtual void on_message_info(uint64 id, int32 state, uint64 answer_id, int32 answer_size) = 0;
|
||||||
|
|
||||||
|
|
|
@ -768,22 +768,22 @@ Status Session::on_message_result_ok(uint64 id, BufferSlice packet, size_t origi
|
||||||
return Status::OK();
|
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
|
// UNAUTHORIZED
|
||||||
if (error_code == 401 && message.as_slice() != CSlice("SESSION_PASSWORD_NEEDED")) {
|
if (error_code == 401 && message != CSlice("SESSION_PASSWORD_NEEDED")) {
|
||||||
if (auth_data_.use_pfs() && message.as_slice() == CSlice("AUTH_KEY_PERM_EMPTY")) {
|
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 "
|
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_.get_tmp_auth_key().id();
|
||||||
auth_data_.drop_tmp_auth_key();
|
auth_data_.drop_tmp_auth_key();
|
||||||
on_tmp_auth_key_updated();
|
on_tmp_auth_key_updated();
|
||||||
error_code = 500;
|
error_code = 500;
|
||||||
} else {
|
} 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 "
|
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.";
|
"write to recover@telegram.org your phone number and other details to recover the account.";
|
||||||
}
|
}
|
||||||
auth_data_.set_auth_flag(false);
|
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());
|
shared_auth_data_->set_auth_key(auth_data_.get_main_auth_key());
|
||||||
on_session_failed(Status::OK());
|
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) {
|
if (error_code < 0) {
|
||||||
LOG(WARNING) << "Session::on_message_result_error from mtproto " << tag("id", id) << tag("error_code", error_code)
|
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 {
|
} else {
|
||||||
LOG(DEBUG) << "Session::on_message_result_error " << tag("id", id) << tag("error_code", error_code)
|
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);
|
auto it = sent_queries_.find(id);
|
||||||
if (it == sent_queries_.end()) {
|
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);
|
cleanup_container(id, query_ptr);
|
||||||
mark_as_known(id, query_ptr);
|
mark_as_known(id, query_ptr);
|
||||||
query_ptr->query->set_error(Status::Error(error_code, message.as_slice()),
|
query_ptr->query->set_error(Status::Error(error_code, message), current_info_->connection->get_name().str());
|
||||||
current_info_->connection->get_name().str());
|
|
||||||
query_ptr->query->set_message_id(0);
|
query_ptr->query->set_message_id(0);
|
||||||
query_ptr->query->cancel_slot_.clear_event();
|
query_ptr->query->cancel_slot_.clear_event();
|
||||||
return_query(std::move(query_ptr->query));
|
return_query(std::move(query_ptr->query));
|
||||||
|
|
|
@ -208,7 +208,7 @@ class Session final
|
||||||
|
|
||||||
void on_message_ack(uint64 id) final;
|
void on_message_ack(uint64 id) final;
|
||||||
Status on_message_result_ok(uint64 id, BufferSlice packet, size_t original_size) 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_failed(uint64 id, Status status) final;
|
||||||
|
|
||||||
void on_message_info(uint64 id, int32 state, uint64 answer_id, int32 answer_size) final;
|
void on_message_info(uint64 id, int32 state, uint64 answer_id, int32 answer_size) final;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user