From e2bbd02d8ca7d14b5d4cebaeb30d627d0328f696 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 3 Oct 2021 14:20:52 +0300 Subject: [PATCH] Check that server returns messages in the correct chat in event log. --- td/telegram/MessagesManager.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index e290abb94..bcff70b69 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -31819,7 +31819,7 @@ tl_object_ptr MessagesManager::get_chat_event_action_ob auto message = create_message( parse_telegram_api_message(std::move(action->message_), false, "channelAdminLogEventActionUpdatePinned"), true); - if (message.second == nullptr) { + if (message.second == nullptr || message.first != DialogId(channel_id)) { LOG(ERROR) << "Failed to get pinned message"; return nullptr; } @@ -31838,7 +31838,8 @@ tl_object_ptr MessagesManager::get_chat_event_action_ob auto new_message = create_message(parse_telegram_api_message(std::move(action->new_message_), false, "new channelAdminLogEventActionEditMessage"), true); - if (old_message.second == nullptr || new_message.second == nullptr || old_message.first != new_message.first) { + if (old_message.second == nullptr || new_message.second == nullptr || old_message.first != new_message.first || + old_message.first != DialogId(channel_id)) { LOG(ERROR) << "Failed to get edited message"; return nullptr; } @@ -31850,7 +31851,7 @@ tl_object_ptr MessagesManager::get_chat_event_action_ob auto action = move_tl_object_as(action_ptr); auto message = create_message( parse_telegram_api_message(std::move(action->message_), false, "channelAdminLogEventActionStopPoll"), true); - if (message.second == nullptr) { + if (message.second == nullptr || message.first != DialogId(channel_id)) { LOG(ERROR) << "Failed to get stopped poll message"; return nullptr; } @@ -31866,7 +31867,7 @@ tl_object_ptr MessagesManager::get_chat_event_action_ob auto message = create_message( parse_telegram_api_message(std::move(action->message_), false, "channelAdminLogEventActionDeleteMessage"), true); - if (message.second == nullptr) { + if (message.second == nullptr || message.first != DialogId(channel_id)) { LOG(ERROR) << "Failed to get deleted message"; return nullptr; }