From 830806937e4ec686117133ea410e8e30b49f41ea Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 17 Nov 2022 14:18:11 +0300 Subject: [PATCH] Improve source type in on_get_channel_error/on_get_dialog_error. --- td/telegram/ContactsManager.cpp | 7 ++++--- td/telegram/ContactsManager.h | 2 +- td/telegram/MessagesManager.cpp | 2 +- td/telegram/MessagesManager.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index cfdde1bea..e8be88a5c 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -13042,7 +13042,7 @@ tl_object_ptr ContactsManager::get_chat_member_object( dialog_participant.joined_date_, dialog_participant.status_.get_chat_member_status_object()); } -bool ContactsManager::on_get_channel_error(ChannelId channel_id, const Status &status, const string &source) { +bool ContactsManager::on_get_channel_error(ChannelId channel_id, const Status &status, const char *source) { LOG(INFO) << "Receive " << status << " in " << channel_id << " from " << source; if (status.message() == CSlice("BOT_METHOD_INVALID")) { LOG(ERROR) << "Receive BOT_METHOD_INVALID from " << source; @@ -13059,7 +13059,8 @@ bool ContactsManager::on_get_channel_error(ChannelId channel_id, const Status &s auto c = get_channel(channel_id); if (c == nullptr) { - if (source == "GetChannelDifferenceQuery" || (td_->auth_manager_->is_bot() && source == "GetChannelsQuery")) { + if (Slice(source) == Slice("GetChannelDifferenceQuery") || + (td_->auth_manager_->is_bot() && Slice(source) == Slice("GetChannelsQuery"))) { // get channel difference after restart // get channel from server by its identifier return true; @@ -13095,7 +13096,7 @@ bool ContactsManager::on_get_channel_error(ChannelId channel_id, const Status &s remove_dialog_access_by_invite_link(DialogId(channel_id)); } - invalidate_channel_full(channel_id, !c->is_slow_mode_enabled, "on_get_channel_error"); + invalidate_channel_full(channel_id, !c->is_slow_mode_enabled, source); LOG_IF(ERROR, have_input_peer_channel(c, channel_id, AccessRights::Read)) << "Have read access to channel after receiving CHANNEL_PRIVATE. Channel state: " << oneline(to_string(get_supergroup_object(channel_id, c))) diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 43594c7e9..0bd30e4d0 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -240,7 +240,7 @@ class ContactsManager final : public Actor { void invalidate_channel_full(ChannelId channel_id, bool need_drop_slow_mode_delay, const char *source); - bool on_get_channel_error(ChannelId channel_id, const Status &status, const string &source); + bool on_get_channel_error(ChannelId channel_id, const Status &status, const char *source); void on_get_permanent_dialog_invite_link(DialogId dialog_id, const DialogInviteLink &invite_link); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 345318981..6c22ee012 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -29994,7 +29994,7 @@ bool MessagesManager::on_update_message_id(int64 random_id, MessageId new_messag return true; } -bool MessagesManager::on_get_dialog_error(DialogId dialog_id, const Status &status, const string &source) { +bool MessagesManager::on_get_dialog_error(DialogId dialog_id, const Status &status, const char *source) { if (status.message() == CSlice("BOT_METHOD_INVALID")) { LOG(ERROR) << "Receive BOT_METHOD_INVALID from " << source; return true; diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 90012b7ef..9b8f3d31c 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -909,7 +909,7 @@ class MessagesManager final : public Actor { void after_get_difference(); - bool on_get_dialog_error(DialogId dialog_id, const Status &status, const string &source); + bool on_get_dialog_error(DialogId dialog_id, const Status &status, const char *source); void on_send_message_get_quick_ack(int64 random_id);