Unify ResultHandler subclass names and logged name.

This commit is contained in:
levlam 2021-02-08 15:56:08 +03:00
parent c226a204fa
commit bf42d62f1e
6 changed files with 49 additions and 51 deletions

View File

@ -1154,13 +1154,13 @@ class ToggleChannelSignaturesQuery : public Td::ResultHandler {
}
};
class ToggleChannelIsAllHistoryAvailableQuery : public Td::ResultHandler {
class TogglePrehistoryHiddenQuery : public Td::ResultHandler {
Promise<Unit> promise_;
ChannelId channel_id_;
bool is_all_history_available_;
public:
explicit ToggleChannelIsAllHistoryAvailableQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
explicit TogglePrehistoryHiddenQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(ChannelId channel_id, bool is_all_history_available) {
@ -1180,7 +1180,7 @@ class ToggleChannelIsAllHistoryAvailableQuery : public Td::ResultHandler {
}
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for TogglePreHistoryHiddenQuery: " << to_string(ptr);
LOG(INFO) << "Receive result for TogglePrehistoryHiddenQuery: " << to_string(ptr);
td->updates_manager_->on_get_updates(
std::move(ptr),
@ -1201,7 +1201,7 @@ class ToggleChannelIsAllHistoryAvailableQuery : public Td::ResultHandler {
return;
}
} else {
td->contacts_manager_->on_get_channel_error(channel_id_, status, "ToggleChannelIsAllHistoryAvailableQuery");
td->contacts_manager_->on_get_channel_error(channel_id_, status, "TogglePrehistoryHiddenQuery");
}
promise_.set_error(std::move(status));
}
@ -1567,12 +1567,12 @@ class EditChatAdminQuery : public Td::ResultHandler {
}
};
class ExportChatInviteLinkQuery : public Td::ResultHandler {
class ExportChatInviteQuery : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::chatInviteLink>> promise_;
DialogId dialog_id_;
public:
explicit ExportChatInviteLinkQuery(Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise)
explicit ExportChatInviteQuery(Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise)
: promise_(std::move(promise)) {
}
@ -1621,7 +1621,7 @@ class ExportChatInviteLinkQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ExportChatInviteLinkQuery");
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ExportChatInviteQuery");
promise_.set_error(std::move(status));
}
};
@ -1884,7 +1884,7 @@ class RevokeChatInviteLinkQuery : public Td::ResultHandler {
}
auto result = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for ExportChatInviteQuery: " << to_string(result);
LOG(INFO) << "Receive result for RevokeChatInviteLinkQuery: " << to_string(result);
vector<td_api::object_ptr<td_api::chatInviteLink>> links;
switch (result->get_id()) {
@ -2002,12 +2002,12 @@ class DeleteRevokedExportedChatInvitesQuery : public Td::ResultHandler {
}
};
class CheckDialogInviteLinkQuery : public Td::ResultHandler {
class CheckChatInviteQuery : public Td::ResultHandler {
Promise<Unit> promise_;
string invite_link_;
public:
explicit CheckDialogInviteLinkQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
explicit CheckChatInviteQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(const string &invite_link) {
@ -2033,13 +2033,13 @@ class CheckDialogInviteLinkQuery : public Td::ResultHandler {
}
};
class ImportDialogInviteLinkQuery : public Td::ResultHandler {
class ImportChatInviteQuery : public Td::ResultHandler {
Promise<DialogId> promise_;
string invite_link_;
public:
explicit ImportDialogInviteLinkQuery(Promise<DialogId> &&promise) : promise_(std::move(promise)) {
explicit ImportChatInviteQuery(Promise<DialogId> &&promise) : promise_(std::move(promise)) {
}
void send(const string &invite_link) {
@ -2059,7 +2059,7 @@ class ImportDialogInviteLinkQuery : public Td::ResultHandler {
auto dialog_ids = UpdatesManager::get_chat_dialog_ids(ptr.get());
if (dialog_ids.size() != 1u) {
LOG(ERROR) << "Receive wrong result for ImportDialogInviteLinkQuery: " << to_string(ptr);
LOG(ERROR) << "Receive wrong result for ImportChatInviteQuery: " << to_string(ptr);
return on_error(id, Status::Error(500, "Internal Server Error"));
}
auto dialog_id = dialog_ids[0];
@ -6152,8 +6152,7 @@ void ContactsManager::toggle_channel_is_all_history_available(ChannelId channel_
}
// it can be toggled in public chats, but will not affect them
td_->create_handler<ToggleChannelIsAllHistoryAvailableQuery>(std::move(promise))
->send(channel_id, is_all_history_available);
td_->create_handler<TogglePrehistoryHiddenQuery>(std::move(promise))->send(channel_id, is_all_history_available);
}
void ContactsManager::set_channel_description(ChannelId channel_id, const string &description,
@ -7006,7 +7005,7 @@ void ContactsManager::export_dialog_invite_link_impl(DialogId dialog_id, int32 e
TRY_STATUS_PROMISE(promise, can_manage_dialog_invite_links(dialog_id));
td_->create_handler<ExportChatInviteLinkQuery>(std::move(promise))
td_->create_handler<ExportChatInviteQuery>(std::move(promise))
->send(dialog_id, expire_date, usage_limit, is_permanent);
}
@ -7102,7 +7101,7 @@ void ContactsManager::check_dialog_invite_link(const string &invite_link, Promis
return promise.set_error(Status::Error(400, "Wrong invite link"));
}
td_->create_handler<CheckDialogInviteLinkQuery>(std::move(promise))->send(invite_link);
td_->create_handler<CheckChatInviteQuery>(std::move(promise))->send(invite_link);
}
void ContactsManager::import_dialog_invite_link(const string &invite_link, Promise<DialogId> &&promise) {
@ -7110,7 +7109,7 @@ void ContactsManager::import_dialog_invite_link(const string &invite_link, Promi
return promise.set_error(Status::Error(400, "Wrong invite link"));
}
td_->create_handler<ImportDialogInviteLinkQuery>(std::move(promise))->send(invite_link);
td_->create_handler<ImportChatInviteQuery>(std::move(promise))->send(invite_link);
}
void ContactsManager::delete_chat_participant(ChatId chat_id, UserId user_id, bool revoke_messages,
@ -11931,7 +11930,7 @@ void ContactsManager::on_get_dialog_invite_link_info(const string &invite_link,
// the access is already expired, reget the info
if (accessible_before != 0 && accessible_before <= G()->unix_time() + 1) {
td_->create_handler<CheckDialogInviteLinkQuery>(std::move(promise))->send(invite_link);
td_->create_handler<CheckChatInviteQuery>(std::move(promise))->send(invite_link);
return;
}

View File

@ -209,8 +209,10 @@ class JoinGroupCallQuery : public Td::ResultHandler {
return on_error(id, result_ptr.move_as_error());
}
td->group_call_manager_->process_join_group_call_response(input_group_call_id_, generation_,
result_ptr.move_as_ok(), std::move(promise_));
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for JoinGroupCallQuery with generation " << generation_ << ": " << to_string(ptr);
td->group_call_manager_->process_join_group_call_response(input_group_call_id_, generation_, std::move(ptr),
std::move(promise_));
}
void on_error(uint64 id, Status status) override {
@ -1642,7 +1644,6 @@ void GroupCallManager::process_join_group_call_response(InputGroupCallId input_g
return;
}
LOG(INFO) << "Receive result for JoinGroupCallQuery: " << to_string(updates);
td_->updates_manager_->on_get_updates(std::move(updates),
PromiseCreator::lambda([promise = std::move(promise)](Unit) mutable {
promise.set_error(Status::Error(500, "Wrong join response received"));

View File

@ -141,11 +141,11 @@ class UpdateDialogFilterQuery : public Td::ResultHandler {
}
};
class ReorderDialogFiltersQuery : public Td::ResultHandler {
class UpdateDialogFiltersOrderQuery : public Td::ResultHandler {
Promise<Unit> promise_;
public:
explicit ReorderDialogFiltersQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
explicit UpdateDialogFiltersOrderQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(vector<DialogFilterId> dialog_filter_ids) {
@ -1329,12 +1329,12 @@ class EditDialogTitleQuery : public Td::ResultHandler {
}
};
class EditDialogDefaultBannedRightsQuery : public Td::ResultHandler {
class EditChatDefaultBannedRightsQuery : public Td::ResultHandler {
Promise<Unit> promise_;
DialogId dialog_id_;
public:
explicit EditDialogDefaultBannedRightsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
explicit EditChatDefaultBannedRightsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(DialogId dialog_id, RestrictedRights permissions) {
@ -1352,7 +1352,7 @@ class EditDialogDefaultBannedRightsQuery : public Td::ResultHandler {
}
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for EditDialogPermissionsQuery: " << to_string(ptr);
LOG(INFO) << "Receive result for EditChatDefaultBannedRightsQuery: " << to_string(ptr);
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
@ -1363,7 +1363,7 @@ class EditDialogDefaultBannedRightsQuery : public Td::ResultHandler {
return;
}
} else {
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditDialogDefaultBannedRightsQuery");
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditChatDefaultBannedRightsQuery");
}
promise_.set_error(std::move(status));
}
@ -2637,7 +2637,7 @@ class DeleteUserHistoryQuery : public Td::ResultHandler {
}
};
class ReadAllMentionsQuery : public Td::ResultHandler {
class ReadMentionsQuery : public Td::ResultHandler {
Promise<Unit> promise_;
DialogId dialog_id_;
@ -2653,7 +2653,7 @@ class ReadAllMentionsQuery : public Td::ResultHandler {
}
public:
explicit ReadAllMentionsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
explicit ReadMentionsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(DialogId dialog_id) {
@ -2673,7 +2673,7 @@ class ReadAllMentionsQuery : public Td::ResultHandler {
if (affected_history->pts_count_ > 0) {
if (dialog_id_.get_type() == DialogType::Channel) {
LOG(ERROR) << "Receive pts_count " << affected_history->pts_count_ << " in result of ReadAllMentionsQuery in "
LOG(ERROR) << "Receive pts_count " << affected_history->pts_count_ << " in result of ReadMentionsQuery in "
<< dialog_id_;
td->updates_manager_->get_difference("Wrong messages_readMentions result");
} else {
@ -2692,7 +2692,7 @@ class ReadAllMentionsQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReadAllMentionsQuery");
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReadMentionsQuery");
promise_.set_error(std::move(status));
}
};
@ -2794,7 +2794,7 @@ class SendMessageActor : public NetActorOnce {
}
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for SendMessageQuery for " << random_id_ << ": " << to_string(ptr);
LOG(INFO) << "Receive result for SendMessage for " << random_id_ << ": " << to_string(ptr);
auto constructor_id = ptr->get_id();
if (constructor_id != telegram_api::updateShortSentMessage::ID) {
@ -2822,7 +2822,7 @@ class SendMessageActor : public NetActorOnce {
}
void on_error(uint64 id, Status status) override {
LOG(INFO) << "Receive error for SendMessageQuery: " << status;
LOG(INFO) << "Receive error for SendMessage: " << status;
if (G()->close_flag() && G()->parameters().use_message_db) {
// do not send error, message will be re-sent
return;
@ -2968,8 +2968,7 @@ class SendMultiMediaActor : public NetActorOnce {
}
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for SendMultiMediaQuery for " << format::as_array(random_ids_) << ": "
<< to_string(ptr);
LOG(INFO) << "Receive result for SendMultiMedia for " << format::as_array(random_ids_) << ": " << to_string(ptr);
auto sent_random_ids = UpdatesManager::get_sent_messages_random_ids(ptr.get());
bool is_result_wrong = false;
@ -3000,7 +2999,7 @@ class SendMultiMediaActor : public NetActorOnce {
}
}
if (is_result_wrong) {
LOG(ERROR) << "Receive wrong result for SendMultiMediaQuery with random_ids " << format::as_array(random_ids_)
LOG(ERROR) << "Receive wrong result for SendMultiMedia with random_ids " << format::as_array(random_ids_)
<< " to " << dialog_id_ << ": " << oneline(to_string(ptr));
td->updates_manager_->schedule_get_difference("Wrong sendMultiMedia result");
}
@ -3009,7 +3008,7 @@ class SendMultiMediaActor : public NetActorOnce {
}
void on_error(uint64 id, Status status) override {
LOG(INFO) << "Receive error for SendMultiMediaQuery: " << status;
LOG(INFO) << "Receive error for SendMultiMedia: " << status;
if (G()->close_flag() && G()->parameters().use_message_db) {
// do not send error, message will be re-sent
return;
@ -3097,13 +3096,13 @@ class SendMediaActor : public NetActorOnce {
}
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for SendMediaQuery for " << random_id_ << ": " << to_string(ptr);
LOG(INFO) << "Receive result for SendMedia for " << random_id_ << ": " << to_string(ptr);
td->messages_manager_->check_send_message_result(random_id_, dialog_id_, ptr.get(), "SendMedia");
td->updates_manager_->on_get_updates(std::move(ptr), Promise<Unit>());
}
void on_error(uint64 id, Status status) override {
LOG(INFO) << "Receive error for SendMediaQuery: " << status;
LOG(INFO) << "Receive error for SendMedia: " << status;
if (G()->close_flag() && G()->parameters().use_message_db) {
// do not send error, message will be re-sent
return;
@ -3348,7 +3347,7 @@ class EditMessageActor : public NetActorOnce {
}
void on_error(uint64 id, Status status) override {
LOG(INFO) << "Receive error for EditMessageQuery: " << status;
LOG(INFO) << "Receive error for EditMessage: " << status;
if (!td->auth_manager_->is_bot() && status.message() == "MESSAGE_NOT_MODIFIED") {
return promise_.set_value(0);
}
@ -3459,12 +3458,12 @@ class SetGameScoreActor : public NetActorOnce {
}
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for SetGameScoreActor: " << to_string(ptr);
LOG(INFO) << "Receive result for SetGameScore: " << to_string(ptr);
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) override {
LOG(INFO) << "Receive error for SetGameScoreQuery: " << status;
LOG(INFO) << "Receive error for SetGameScore: " << status;
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetGameScoreActor");
promise_.set_error(std::move(status));
}
@ -3647,8 +3646,7 @@ class ForwardMessagesActor : public NetActorOnce {
}
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for ForwardMessagesQuery for " << format::as_array(random_ids_) << ": "
<< to_string(ptr);
LOG(INFO) << "Receive result for ForwardMessages for " << format::as_array(random_ids_) << ": " << to_string(ptr);
auto sent_random_ids = UpdatesManager::get_sent_messages_random_ids(ptr.get());
bool is_result_wrong = false;
auto sent_random_ids_size = sent_random_ids.size();
@ -11006,7 +11004,7 @@ void MessagesManager::read_all_dialog_mentions_on_server(DialogId dialog_id, uin
}
LOG(INFO) << "Read all mentions on server in " << dialog_id;
td_->create_handler<ReadAllMentionsQuery>(get_erase_log_event_promise(log_event_id, std::move(promise)))
td_->create_handler<ReadMentionsQuery>(get_erase_log_event_promise(log_event_id, std::move(promise)))
->send(dialog_id);
}
@ -17795,7 +17793,7 @@ void MessagesManager::reorder_dialog_filters_on_server(vector<DialogFilterId> di
send_closure(actor_id, &MessagesManager::on_reorder_dialog_filters, std::move(dialog_filter_ids),
result.is_error() ? result.move_as_error() : Status::OK());
});
td_->create_handler<ReorderDialogFiltersQuery>(std::move(promise))->send(std::move(dialog_filter_ids));
td_->create_handler<UpdateDialogFiltersOrderQuery>(std::move(promise))->send(std::move(dialog_filter_ids));
}
void MessagesManager::on_reorder_dialog_filters(vector<DialogFilterId> dialog_filter_ids, Status result) {
@ -30707,7 +30705,7 @@ void MessagesManager::set_dialog_permissions(DialogId dialog_id,
}
// TODO invoke after
td_->create_handler<EditDialogDefaultBannedRightsQuery>(std::move(promise))->send(dialog_id, new_permissions);
td_->create_handler<EditChatDefaultBannedRightsQuery>(std::move(promise))->send(dialog_id, new_permissions);
}
void MessagesManager::set_dialog_description(DialogId dialog_id, const string &description, Promise<Unit> &&promise) {

View File

@ -224,7 +224,7 @@ class StopPollActor : public NetActorOnce {
}
auto result = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for StopPollQuery: " << to_string(result);
LOG(INFO) << "Receive result for StopPoll: " << to_string(result);
td->updates_manager_->on_get_updates(std::move(result), std::move(promise_));
}

View File

@ -3137,7 +3137,7 @@ void Td::on_get_promo_data(Result<telegram_api::object_ptr<telegram_api::help_Pr
}
if (r_promo_data.is_error()) {
LOG(ERROR) << "Receive error for GetPromoDataQuery: " << r_promo_data.error();
LOG(ERROR) << "Receive error for GetPromoData: " << r_promo_data.error();
return schedule_get_promo_data(60);
}

View File

@ -77,7 +77,7 @@ void PublicRsaKeyWatchdog::on_result(NetQueryPtr net_query) {
has_query_ = false;
yield();
if (net_query->is_error()) {
LOG(ERROR) << "Receive error for GetCdnConfigQuery: " << net_query->move_as_error();
LOG(ERROR) << "Receive error for GetCdnConfig: " << net_query->move_as_error();
return;
}