Reduce "this" usages.
This commit is contained in:
parent
0c1469f7c6
commit
c24501f2d9
@ -112,8 +112,7 @@ class QueryImpl {
|
|||||||
void do_store(StorerT &storer) const {
|
void do_store(StorerT &storer) const {
|
||||||
storer.store_binary(query_.message_id);
|
storer.store_binary(query_.message_id);
|
||||||
storer.store_binary(query_.seq_no);
|
storer.store_binary(query_.seq_no);
|
||||||
Slice header = this->header_;
|
Slice invoke_header;
|
||||||
Slice invoke_header = Slice();
|
|
||||||
|
|
||||||
// TODO(refactor):
|
// TODO(refactor):
|
||||||
// invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
|
// invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
|
||||||
@ -138,7 +137,7 @@ class QueryImpl {
|
|||||||
const Storer &data_storer =
|
const Storer &data_storer =
|
||||||
query_.gzip_flag ? static_cast<const Storer &>(gzip_storer) : static_cast<const Storer &>(plain_storer);
|
query_.gzip_flag ? static_cast<const Storer &>(gzip_storer) : static_cast<const Storer &>(plain_storer);
|
||||||
auto invoke_header_storer = create_storer(invoke_header);
|
auto invoke_header_storer = create_storer(invoke_header);
|
||||||
auto header_storer = create_storer(header);
|
auto header_storer = create_storer(header_);
|
||||||
auto suff_storer = create_storer(invoke_header_storer, data_storer);
|
auto suff_storer = create_storer(invoke_header_storer, data_storer);
|
||||||
auto all_storer = create_storer(header_storer, suff_storer);
|
auto all_storer = create_storer(header_storer, suff_storer);
|
||||||
|
|
||||||
|
@ -3128,20 +3128,23 @@ tl_object_ptr<td_api::chatStatisticsSupergroup> ContactsManager::convert_megagro
|
|||||||
td::remove_if(obj->top_inviters_,
|
td::remove_if(obj->top_inviters_,
|
||||||
[](auto &obj) { return !UserId(obj->user_id_).is_valid() || obj->invitations_ < 0; });
|
[](auto &obj) { return !UserId(obj->user_id_).is_valid() || obj->invitations_ < 0; });
|
||||||
|
|
||||||
auto top_senders = transform(std::move(obj->top_posters_), [this](auto &&top_poster) {
|
auto top_senders =
|
||||||
return td_api::make_object<td_api::chatStatisticsMessageSenderInfo>(
|
transform(std::move(obj->top_posters_), [this](tl_object_ptr<telegram_api::statsGroupTopPoster> &&top_poster) {
|
||||||
this->get_user_id_object(UserId(top_poster->user_id_), "get_top_senders"), top_poster->messages_,
|
return td_api::make_object<td_api::chatStatisticsMessageSenderInfo>(
|
||||||
top_poster->avg_chars_);
|
get_user_id_object(UserId(top_poster->user_id_), "get_top_senders"), top_poster->messages_,
|
||||||
});
|
top_poster->avg_chars_);
|
||||||
auto top_administrators = transform(std::move(obj->top_admins_), [this](auto &&top_admin) {
|
});
|
||||||
return td_api::make_object<td_api::chatStatisticsAdministratorActionsInfo>(
|
auto top_administrators =
|
||||||
this->get_user_id_object(UserId(top_admin->user_id_), "get_top_administrators"), top_admin->deleted_,
|
transform(std::move(obj->top_admins_), [this](tl_object_ptr<telegram_api::statsGroupTopAdmin> &&top_admin) {
|
||||||
top_admin->kicked_, top_admin->banned_);
|
return td_api::make_object<td_api::chatStatisticsAdministratorActionsInfo>(
|
||||||
});
|
get_user_id_object(UserId(top_admin->user_id_), "get_top_administrators"), top_admin->deleted_,
|
||||||
auto top_inviters = transform(std::move(obj->top_inviters_), [this](auto &&top_inviter) {
|
top_admin->kicked_, top_admin->banned_);
|
||||||
return td_api::make_object<td_api::chatStatisticsInviterInfo>(
|
});
|
||||||
this->get_user_id_object(UserId(top_inviter->user_id_), "get_top_inviters"), top_inviter->invitations_);
|
auto top_inviters =
|
||||||
});
|
transform(std::move(obj->top_inviters_), [this](tl_object_ptr<telegram_api::statsGroupTopInviter> &&top_inviter) {
|
||||||
|
return td_api::make_object<td_api::chatStatisticsInviterInfo>(
|
||||||
|
get_user_id_object(UserId(top_inviter->user_id_), "get_top_inviters"), top_inviter->invitations_);
|
||||||
|
});
|
||||||
|
|
||||||
return make_tl_object<td_api::chatStatisticsSupergroup>(
|
return make_tl_object<td_api::chatStatisticsSupergroup>(
|
||||||
convert_date_range(obj->period_), convert_stats_absolute_value(obj->members_),
|
convert_date_range(obj->period_), convert_stats_absolute_value(obj->members_),
|
||||||
|
@ -2739,12 +2739,12 @@ class BlockFromRepliesQuery final : public Td::ResultHandler {
|
|||||||
explicit BlockFromRepliesQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
explicit BlockFromRepliesQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(MessageId message_id, bool delete_message, bool delete_all_messages, bool report_spam) {
|
void send(MessageId message_id, bool need_delete_message, bool need_delete_all_messages, bool report_spam) {
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
if (delete_message) {
|
if (need_delete_message) {
|
||||||
flags |= telegram_api::contacts_blockFromReplies::DELETE_MESSAGE_MASK;
|
flags |= telegram_api::contacts_blockFromReplies::DELETE_MESSAGE_MASK;
|
||||||
}
|
}
|
||||||
if (delete_all_messages) {
|
if (need_delete_all_messages) {
|
||||||
flags |= telegram_api::contacts_blockFromReplies::DELETE_HISTORY_MASK;
|
flags |= telegram_api::contacts_blockFromReplies::DELETE_HISTORY_MASK;
|
||||||
}
|
}
|
||||||
if (report_spam) {
|
if (report_spam) {
|
||||||
@ -16623,8 +16623,8 @@ void MessagesManager::on_get_common_dialogs(UserId user_id, int64 offset_chat_id
|
|||||||
common_dialogs.total_count = total_count;
|
common_dialogs.total_count = total_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::block_message_sender_from_replies(MessageId message_id, bool delete_message,
|
void MessagesManager::block_message_sender_from_replies(MessageId message_id, bool need_delete_message,
|
||||||
bool delete_all_messages, bool report_spam,
|
bool need_delete_all_messages, bool report_spam,
|
||||||
Promise<Unit> &&promise) {
|
Promise<Unit> &&promise) {
|
||||||
auto dialog_id = DialogId(ContactsManager::get_replies_bot_user_id());
|
auto dialog_id = DialogId(ContactsManager::get_replies_bot_user_id());
|
||||||
Dialog *d = get_dialog_force(dialog_id, "block_message_sender_from_replies");
|
Dialog *d = get_dialog_force(dialog_id, "block_message_sender_from_replies");
|
||||||
@ -16649,20 +16649,19 @@ void MessagesManager::block_message_sender_from_replies(MessageId message_id, bo
|
|||||||
}
|
}
|
||||||
bool need_update_dialog_pos = false;
|
bool need_update_dialog_pos = false;
|
||||||
vector<int64> deleted_message_ids;
|
vector<int64> deleted_message_ids;
|
||||||
if (delete_message) {
|
if (need_delete_message) {
|
||||||
auto p = this->delete_message(d, message_id, true, &need_update_dialog_pos, "block_message_sender_from_replies");
|
auto p = delete_message(d, message_id, true, &need_update_dialog_pos, "block_message_sender_from_replies");
|
||||||
CHECK(p.get() == m);
|
CHECK(p.get() == m);
|
||||||
deleted_message_ids.push_back(p->message_id.get());
|
deleted_message_ids.push_back(p->message_id.get());
|
||||||
}
|
}
|
||||||
if (delete_all_messages && sender_user_id.is_valid()) {
|
if (need_delete_all_messages && sender_user_id.is_valid()) {
|
||||||
vector<MessageId> message_ids;
|
vector<MessageId> message_ids;
|
||||||
find_messages(d->messages.get(), message_ids, [sender_user_id](const Message *m) {
|
find_messages(d->messages.get(), message_ids, [sender_user_id](const Message *m) {
|
||||||
return !m->is_outgoing && m->forward_info != nullptr && m->forward_info->sender_user_id == sender_user_id;
|
return !m->is_outgoing && m->forward_info != nullptr && m->forward_info->sender_user_id == sender_user_id;
|
||||||
});
|
});
|
||||||
|
|
||||||
for (auto user_message_id : message_ids) {
|
for (auto user_message_id : message_ids) {
|
||||||
auto p = this->delete_message(d, user_message_id, true, &need_update_dialog_pos,
|
auto p = delete_message(d, user_message_id, true, &need_update_dialog_pos, "block_message_sender_from_replies 2");
|
||||||
"block_message_sender_from_replies 2");
|
|
||||||
deleted_message_ids.push_back(p->message_id.get());
|
deleted_message_ids.push_back(p->message_id.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -16673,7 +16672,7 @@ void MessagesManager::block_message_sender_from_replies(MessageId message_id, bo
|
|||||||
|
|
||||||
send_update_delete_messages(dialog_id, std::move(deleted_message_ids), true, false);
|
send_update_delete_messages(dialog_id, std::move(deleted_message_ids), true, false);
|
||||||
|
|
||||||
block_message_sender_from_replies_on_server(message_id, delete_message, delete_all_messages, report_spam, 0,
|
block_message_sender_from_replies_on_server(message_id, need_delete_message, need_delete_all_messages, report_spam, 0,
|
||||||
std::move(promise));
|
std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16708,24 +16707,25 @@ class MessagesManager::BlockMessageSenderFromRepliesOnServerLogEvent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
uint64 MessagesManager::save_block_message_sender_from_replies_on_server_log_event(MessageId message_id,
|
uint64 MessagesManager::save_block_message_sender_from_replies_on_server_log_event(MessageId message_id,
|
||||||
bool delete_message,
|
bool need_delete_message,
|
||||||
bool delete_all_messages,
|
bool need_delete_all_messages,
|
||||||
bool report_spam) {
|
bool report_spam) {
|
||||||
BlockMessageSenderFromRepliesOnServerLogEvent log_event{message_id, delete_message, delete_all_messages, report_spam};
|
BlockMessageSenderFromRepliesOnServerLogEvent log_event{message_id, need_delete_message, need_delete_all_messages,
|
||||||
|
report_spam};
|
||||||
return binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::BlockMessageSenderFromRepliesOnServer,
|
return binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::BlockMessageSenderFromRepliesOnServer,
|
||||||
get_log_event_storer(log_event));
|
get_log_event_storer(log_event));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::block_message_sender_from_replies_on_server(MessageId message_id, bool delete_message,
|
void MessagesManager::block_message_sender_from_replies_on_server(MessageId message_id, bool need_delete_message,
|
||||||
bool delete_all_messages, bool report_spam,
|
bool need_delete_all_messages, bool report_spam,
|
||||||
uint64 log_event_id, Promise<Unit> &&promise) {
|
uint64 log_event_id, Promise<Unit> &&promise) {
|
||||||
if (log_event_id == 0) {
|
if (log_event_id == 0) {
|
||||||
log_event_id = save_block_message_sender_from_replies_on_server_log_event(message_id, delete_message,
|
log_event_id = save_block_message_sender_from_replies_on_server_log_event(message_id, need_delete_message,
|
||||||
delete_all_messages, report_spam);
|
need_delete_all_messages, report_spam);
|
||||||
}
|
}
|
||||||
|
|
||||||
td_->create_handler<BlockFromRepliesQuery>(get_erase_log_event_promise(log_event_id, std::move(promise)))
|
td_->create_handler<BlockFromRepliesQuery>(get_erase_log_event_promise(log_event_id, std::move(promise)))
|
||||||
->send(message_id, delete_message, delete_all_messages, report_spam);
|
->send(message_id, need_delete_message, need_delete_all_messages, report_spam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::get_blocked_dialogs(int32 offset, int32 limit,
|
void MessagesManager::get_blocked_dialogs(int32 offset, int32 limit,
|
||||||
|
@ -544,7 +544,7 @@ class MessagesManager final : public Actor {
|
|||||||
std::pair<int32, vector<DialogId>> get_common_dialogs(UserId user_id, DialogId offset_dialog_id, int32 limit,
|
std::pair<int32, vector<DialogId>> get_common_dialogs(UserId user_id, DialogId offset_dialog_id, int32 limit,
|
||||||
bool force, Promise<Unit> &&promise);
|
bool force, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void block_message_sender_from_replies(MessageId message_id, bool delete_message, bool delete_all_messages,
|
void block_message_sender_from_replies(MessageId message_id, bool need_delete_message, bool need_delete_all_messages,
|
||||||
bool report_spam, Promise<Unit> &&promise);
|
bool report_spam, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void get_blocked_dialogs(int32 offset, int32 limit, Promise<td_api::object_ptr<td_api::messageSenders>> &&promise);
|
void get_blocked_dialogs(int32 offset, int32 limit, Promise<td_api::object_ptr<td_api::messageSenders>> &&promise);
|
||||||
@ -1986,8 +1986,9 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
void delete_all_call_messages_from_server(bool revoke, uint64 log_event_id, Promise<Unit> &&promise);
|
void delete_all_call_messages_from_server(bool revoke, uint64 log_event_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void block_message_sender_from_replies_on_server(MessageId message_id, bool delete_message, bool delete_all_messages,
|
void block_message_sender_from_replies_on_server(MessageId message_id, bool need_delete_message,
|
||||||
bool report_spam, uint64 log_event_id, Promise<Unit> &&promise);
|
bool need_delete_all_messages, bool report_spam, uint64 log_event_id,
|
||||||
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
void delete_all_channel_messages_from_user_on_server(ChannelId channel_id, UserId user_id, uint64 log_event_id,
|
void delete_all_channel_messages_from_user_on_server(ChannelId channel_id, UserId user_id, uint64 log_event_id,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
@ -3052,8 +3053,10 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
static uint64 save_delete_all_call_messages_from_server_log_event(bool revoke);
|
static uint64 save_delete_all_call_messages_from_server_log_event(bool revoke);
|
||||||
|
|
||||||
static uint64 save_block_message_sender_from_replies_on_server_log_event(MessageId message_id, bool delete_message,
|
static uint64 save_block_message_sender_from_replies_on_server_log_event(MessageId message_id,
|
||||||
bool delete_all_messages, bool report_spam);
|
bool need_delete_message,
|
||||||
|
bool need_delete_all_messages,
|
||||||
|
bool report_spam);
|
||||||
|
|
||||||
static uint64 save_delete_all_channel_messages_from_user_on_server_log_event(ChannelId channel_id, UserId user_id);
|
static uint64 save_delete_all_channel_messages_from_user_on_server_log_event(ChannelId channel_id, UserId user_id);
|
||||||
|
|
||||||
|
@ -1565,8 +1565,8 @@ void SecretChatActor::on_outbound_send_message_result(NetQueryPtr query, Promise
|
|||||||
LOG(INFO) << "Outbound secret message [send_message] failed, rewrite it with dummy "
|
LOG(INFO) << "Outbound secret message [send_message] failed, rewrite it with dummy "
|
||||||
<< tag("log_event_id", state->message->log_event_id()) << tag("error", error);
|
<< tag("log_event_id", state->message->log_event_id()) << tag("error", error);
|
||||||
state->send_result_ = [this, random_id = state->message->random_id, error_code = error.code(),
|
state->send_result_ = [this, random_id = state->message->random_id, error_code = error.code(),
|
||||||
error_message = error.message()](Promise<> promise) {
|
error_message = error.message().str()](Promise<> promise) {
|
||||||
this->context_->on_send_message_error(random_id, Status::Error(error_code, error_message), std::move(promise));
|
context_->on_send_message_error(random_id, Status::Error(error_code, error_message), std::move(promise));
|
||||||
};
|
};
|
||||||
state->send_result_(std::move(send_message_error_promise));
|
state->send_result_(std::move(send_message_error_promise));
|
||||||
} else {
|
} else {
|
||||||
@ -1598,7 +1598,7 @@ void SecretChatActor::on_outbound_send_message_result(NetQueryPtr query, Promise
|
|||||||
state->send_result_ = [this, random_id = state->message->random_id,
|
state->send_result_ = [this, random_id = state->message->random_id,
|
||||||
message_id = MessageId(ServerMessageId(state->message->message_id)),
|
message_id = MessageId(ServerMessageId(state->message->message_id)),
|
||||||
date = sent->date_](Promise<> promise) {
|
date = sent->date_](Promise<> promise) {
|
||||||
this->context_->on_send_message_ok(random_id, message_id, date, nullptr, std::move(promise));
|
context_->on_send_message_ok(random_id, message_id, date, nullptr, std::move(promise));
|
||||||
};
|
};
|
||||||
state->send_result_(std::move(send_message_finish_promise));
|
state->send_result_(std::move(send_message_finish_promise));
|
||||||
return;
|
return;
|
||||||
@ -1611,7 +1611,7 @@ void SecretChatActor::on_outbound_send_message_result(NetQueryPtr query, Promise
|
|||||||
state->send_result_ = [this, random_id = state->message->random_id,
|
state->send_result_ = [this, random_id = state->message->random_id,
|
||||||
message_id = MessageId(ServerMessageId(state->message->message_id)),
|
message_id = MessageId(ServerMessageId(state->message->message_id)),
|
||||||
date = sent->date_](Promise<> promise) {
|
date = sent->date_](Promise<> promise) {
|
||||||
this->context_->on_send_message_ok(random_id, message_id, date, nullptr, std::move(promise));
|
context_->on_send_message_ok(random_id, message_id, date, nullptr, std::move(promise));
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
state->message->file = log_event::EncryptedInputFile::from_input_encrypted_file(
|
state->message->file = log_event::EncryptedInputFile::from_input_encrypted_file(
|
||||||
@ -1619,8 +1619,8 @@ void SecretChatActor::on_outbound_send_message_result(NetQueryPtr query, Promise
|
|||||||
state->send_result_ = [this, random_id = state->message->random_id,
|
state->send_result_ = [this, random_id = state->message->random_id,
|
||||||
message_id = MessageId(ServerMessageId(state->message->message_id)),
|
message_id = MessageId(ServerMessageId(state->message->message_id)),
|
||||||
date = sent->date_, file = *file](Promise<> promise) {
|
date = sent->date_, file = *file](Promise<> promise) {
|
||||||
this->context_->on_send_message_ok(random_id, message_id, date, make_unique<EncryptedFile>(file),
|
context_->on_send_message_ok(random_id, message_id, date, make_unique<EncryptedFile>(file),
|
||||||
std::move(promise));
|
std::move(promise));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
state->send_result_(std::move(send_message_finish_promise));
|
state->send_result_(std::move(send_message_finish_promise));
|
||||||
|
@ -302,8 +302,9 @@ void FileLoader::on_result(NetQueryPtr query) {
|
|||||||
if (next) {
|
if (next) {
|
||||||
if (ordered_flag_) {
|
if (ordered_flag_) {
|
||||||
auto seq_no = part.id;
|
auto seq_no = part.id;
|
||||||
ordered_parts_.add(seq_no, std::make_pair(part, std::move(query)),
|
ordered_parts_.add(
|
||||||
[this](auto seq_no, auto &&p) { this->on_part_query(p.first, std::move(p.second)); });
|
seq_no, std::make_pair(part, std::move(query)),
|
||||||
|
[this](uint64 seq_no, std::pair<Part, NetQueryPtr> &&p) { on_part_query(p.first, std::move(p.second)); });
|
||||||
} else {
|
} else {
|
||||||
on_part_query(part, std::move(query));
|
on_part_query(part, std::move(query));
|
||||||
}
|
}
|
||||||
|
@ -826,7 +826,7 @@ FileManager::FileManager(unique_ptr<Context> context) : context_(std::move(conte
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
G()->td_db()->with_db_path([this](CSlice path) { this->bad_paths_.insert(path.str()); });
|
G()->td_db()->with_db_path([bad_paths = &bad_paths_](CSlice path) { bad_paths->insert(path.str()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileManager::init_actor() {
|
void FileManager::init_actor() {
|
||||||
@ -3738,9 +3738,10 @@ void FileManager::on_error_impl(FileNodePtr node, Query::Type type, bool was_act
|
|||||||
if (FileReferenceManager::is_file_reference_error(status)) {
|
if (FileReferenceManager::is_file_reference_error(status)) {
|
||||||
string file_reference;
|
string file_reference;
|
||||||
Slice prefix = "#BASE64";
|
Slice prefix = "#BASE64";
|
||||||
auto pos = status.message().rfind('#');
|
Slice error_message = status.message();
|
||||||
if (pos < status.message().size() && begins_with(status.message().substr(pos), prefix)) {
|
auto pos = error_message.rfind('#');
|
||||||
auto r_file_reference = base64_decode(status.message().substr(pos + prefix.size()));
|
if (pos < error_message.size() && begins_with(error_message.substr(pos), prefix)) {
|
||||||
|
auto r_file_reference = base64_decode(error_message.substr(pos + prefix.size()));
|
||||||
if (r_file_reference.is_ok()) {
|
if (r_file_reference.is_ok()) {
|
||||||
file_reference = r_file_reference.move_as_ok();
|
file_reference = r_file_reference.move_as_ok();
|
||||||
} else {
|
} else {
|
||||||
|
@ -558,10 +558,10 @@ class FileManager final : public FileLoadManager::Callback {
|
|||||||
mutable FileLocationSource file_location_source_;
|
mutable FileLocationSource file_location_source_;
|
||||||
FileId file_id_;
|
FileId file_id_;
|
||||||
bool operator==(const RemoteInfo &other) const {
|
bool operator==(const RemoteInfo &other) const {
|
||||||
return this->remote_ == other.remote_;
|
return remote_ == other.remote_;
|
||||||
}
|
}
|
||||||
bool operator<(const RemoteInfo &other) const {
|
bool operator<(const RemoteInfo &other) const {
|
||||||
return this->remote_ < other.remote_;
|
return remote_ < other.remote_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Enumerator<RemoteInfo> remote_location_info_;
|
Enumerator<RemoteInfo> remote_location_info_;
|
||||||
|
@ -28,16 +28,16 @@ void NetQueryDelayer::delay(NetQueryPtr query) {
|
|||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
// skip
|
// skip
|
||||||
} else if (code == 500) {
|
} else if (code == 500) {
|
||||||
auto msg = query->error().message();
|
auto error_message = query->error().message();
|
||||||
if (msg == "WORKER_BUSY_TOO_LONG_RETRY") {
|
if (error_message == "WORKER_BUSY_TOO_LONG_RETRY") {
|
||||||
timeout = 1; // it is dangerous to resend query without timeout, so use 1
|
timeout = 1; // it is dangerous to resend query without timeout, so use 1
|
||||||
}
|
}
|
||||||
} else if (code == 420) {
|
} else if (code == 420) {
|
||||||
auto msg = query->error().message();
|
auto error_message = query->error().message();
|
||||||
for (auto prefix :
|
for (auto prefix :
|
||||||
{Slice("FLOOD_WAIT_"), Slice("SLOWMODE_WAIT_"), Slice("2FA_CONFIRM_WAIT_"), Slice("TAKEOUT_INIT_DELAY_")}) {
|
{Slice("FLOOD_WAIT_"), Slice("SLOWMODE_WAIT_"), Slice("2FA_CONFIRM_WAIT_"), Slice("TAKEOUT_INIT_DELAY_")}) {
|
||||||
if (begins_with(msg, prefix)) {
|
if (begins_with(error_message, prefix)) {
|
||||||
timeout = clamp(to_integer<int>(msg.substr(prefix.size())), 1, 14 * 24 * 60 * 60);
|
timeout = clamp(to_integer<int>(error_message.substr(prefix.size())), 1, 14 * 24 * 60 * 60);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,15 +294,15 @@ NetQueryDispatcher::NetQueryDispatcher() = default;
|
|||||||
NetQueryDispatcher::~NetQueryDispatcher() = default;
|
NetQueryDispatcher::~NetQueryDispatcher() = default;
|
||||||
|
|
||||||
void NetQueryDispatcher::try_fix_migrate(NetQueryPtr &net_query) {
|
void NetQueryDispatcher::try_fix_migrate(NetQueryPtr &net_query) {
|
||||||
auto msg = net_query->error().message();
|
auto error_message = net_query->error().message();
|
||||||
static constexpr CSlice prefixes[] = {"PHONE_MIGRATE_", "NETWORK_MIGRATE_", "USER_MIGRATE_"};
|
static constexpr CSlice prefixes[] = {"PHONE_MIGRATE_", "NETWORK_MIGRATE_", "USER_MIGRATE_"};
|
||||||
for (auto &prefix : prefixes) {
|
for (auto &prefix : prefixes) {
|
||||||
if (msg.substr(0, prefix.size()) == prefix) {
|
if (error_message.substr(0, prefix.size()) == prefix) {
|
||||||
auto new_main_dc_id = to_integer<int32>(msg.substr(prefix.size()));
|
auto new_main_dc_id = to_integer<int32>(error_message.substr(prefix.size()));
|
||||||
set_main_dc_id(new_main_dc_id);
|
set_main_dc_id(new_main_dc_id);
|
||||||
|
|
||||||
if (!net_query->dc_id().is_main()) {
|
if (!net_query->dc_id().is_main()) {
|
||||||
LOG(ERROR) << msg << " from query to non-main dc " << net_query->dc_id();
|
LOG(ERROR) << "Receive " << error_message << " for query to non-main DC" << net_query->dc_id();
|
||||||
net_query->resend(DcId::internal(new_main_dc_id));
|
net_query->resend(DcId::internal(new_main_dc_id));
|
||||||
} else {
|
} else {
|
||||||
net_query->resend();
|
net_query->resend();
|
||||||
|
Loading…
Reference in New Issue
Block a user