From bf42d62f1e3bc788b629480f1770f9a356e01154 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 8 Feb 2021 15:56:08 +0300 Subject: [PATCH] Unify ResultHandler subclass names and logged name. --- td/telegram/ContactsManager.cpp | 37 +++++++++--------- td/telegram/GroupCallManager.cpp | 7 ++-- td/telegram/MessagesManager.cpp | 50 ++++++++++++------------ td/telegram/PollManager.cpp | 2 +- td/telegram/Td.cpp | 2 +- td/telegram/net/PublicRsaKeyWatchdog.cpp | 2 +- 6 files changed, 49 insertions(+), 51 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 12eb411f8..4e991ceb5 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -1154,13 +1154,13 @@ class ToggleChannelSignaturesQuery : public Td::ResultHandler { } }; -class ToggleChannelIsAllHistoryAvailableQuery : public Td::ResultHandler { +class TogglePrehistoryHiddenQuery : public Td::ResultHandler { Promise promise_; ChannelId channel_id_; bool is_all_history_available_; public: - explicit ToggleChannelIsAllHistoryAvailableQuery(Promise &&promise) : promise_(std::move(promise)) { + explicit TogglePrehistoryHiddenQuery(Promise &&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> promise_; DialogId dialog_id_; public: - explicit ExportChatInviteLinkQuery(Promise> &&promise) + explicit ExportChatInviteQuery(Promise> &&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> 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 promise_; string invite_link_; public: - explicit CheckDialogInviteLinkQuery(Promise &&promise) : promise_(std::move(promise)) { + explicit CheckChatInviteQuery(Promise &&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 promise_; string invite_link_; public: - explicit ImportDialogInviteLinkQuery(Promise &&promise) : promise_(std::move(promise)) { + explicit ImportChatInviteQuery(Promise &&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(std::move(promise)) - ->send(channel_id, is_all_history_available); + td_->create_handler(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(std::move(promise)) + td_->create_handler(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(std::move(promise))->send(invite_link); + td_->create_handler(std::move(promise))->send(invite_link); } void ContactsManager::import_dialog_invite_link(const string &invite_link, Promise &&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(std::move(promise))->send(invite_link); + td_->create_handler(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(std::move(promise))->send(invite_link); + td_->create_handler(std::move(promise))->send(invite_link); return; } diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index 53de8a21d..69d703661 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -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")); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 7b1a5c0b6..7364f72b6 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -141,11 +141,11 @@ class UpdateDialogFilterQuery : public Td::ResultHandler { } }; -class ReorderDialogFiltersQuery : public Td::ResultHandler { +class UpdateDialogFiltersOrderQuery : public Td::ResultHandler { Promise promise_; public: - explicit ReorderDialogFiltersQuery(Promise &&promise) : promise_(std::move(promise)) { + explicit UpdateDialogFiltersOrderQuery(Promise &&promise) : promise_(std::move(promise)) { } void send(vector dialog_filter_ids) { @@ -1329,12 +1329,12 @@ class EditDialogTitleQuery : public Td::ResultHandler { } }; -class EditDialogDefaultBannedRightsQuery : public Td::ResultHandler { +class EditChatDefaultBannedRightsQuery : public Td::ResultHandler { Promise promise_; DialogId dialog_id_; public: - explicit EditDialogDefaultBannedRightsQuery(Promise &&promise) : promise_(std::move(promise)) { + explicit EditChatDefaultBannedRightsQuery(Promise &&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 promise_; DialogId dialog_id_; @@ -2653,7 +2653,7 @@ class ReadAllMentionsQuery : public Td::ResultHandler { } public: - explicit ReadAllMentionsQuery(Promise &&promise) : promise_(std::move(promise)) { + explicit ReadMentionsQuery(Promise &&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()); } 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(get_erase_log_event_promise(log_event_id, std::move(promise))) + td_->create_handler(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 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(std::move(promise))->send(std::move(dialog_filter_ids)); + td_->create_handler(std::move(promise))->send(std::move(dialog_filter_ids)); } void MessagesManager::on_reorder_dialog_filters(vector dialog_filter_ids, Status result) { @@ -30707,7 +30705,7 @@ void MessagesManager::set_dialog_permissions(DialogId dialog_id, } // TODO invoke after - td_->create_handler(std::move(promise))->send(dialog_id, new_permissions); + td_->create_handler(std::move(promise))->send(dialog_id, new_permissions); } void MessagesManager::set_dialog_description(DialogId dialog_id, const string &description, Promise &&promise) { diff --git a/td/telegram/PollManager.cpp b/td/telegram/PollManager.cpp index c34a2ad19..fd15dfb11 100644 --- a/td/telegram/PollManager.cpp +++ b/td/telegram/PollManager.cpp @@ -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_)); } diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 6208ebc78..2f99ccfcd 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -3137,7 +3137,7 @@ void Td::on_get_promo_data(Resultis_error()) { - LOG(ERROR) << "Receive error for GetCdnConfigQuery: " << net_query->move_as_error(); + LOG(ERROR) << "Receive error for GetCdnConfig: " << net_query->move_as_error(); return; }