From b9d4d5767862f51293b105ffdb4edaa6742ca2c9 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 18 Mar 2024 11:54:29 +0300 Subject: [PATCH] Support business messages in need_skip_update_message. --- telegram-bot-api/Client.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 23e4e04..0edfad3 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -12562,9 +12562,17 @@ td::int64 Client::choose_added_member_id(const td_api::messageChatAddMembers *me } bool Client::need_skip_update_message(int64 chat_id, const object_ptr &message, bool is_edited) const { - auto chat = get_chat(chat_id); - CHECK(chat != nullptr); - if (message->is_outgoing_) { + const ChatInfo *chat; + ChatInfo::Type chat_type; + if (chat_id != 0) { + chat = get_chat(chat_id); + CHECK(chat != nullptr); + chat_type = chat->type; + } else { + chat = nullptr; + chat_type = ChatInfo::Type::Private; + } + if (message->is_outgoing_ && chat_id != 0) { switch (message->content_->get_id()) { case td_api::messageChatChangeTitle::ID: case td_api::messageChatChangePhoto::ID: @@ -12600,7 +12608,8 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptrtype == ChatInfo::Type::Supergroup) { + if (chat_type == ChatInfo::Type::Supergroup) { + CHECK(chat != nullptr); auto supergroup_info = get_supergroup_info(chat->supergroup_id); if (supergroup_info->status->get_id() == td_api::chatMemberStatusLeft::ID || supergroup_info->status->get_id() == td_api::chatMemberStatusBanned::ID) { @@ -12641,7 +12650,7 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptrtype != ChatInfo::Type::Supergroup) { + if (chat_type != ChatInfo::Type::Supergroup) { LOG(ERROR) << "Receive messageSupergroupChatCreate in the non-supergroup chat " << chat_id; return true; } @@ -12698,7 +12707,7 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptrid_, true); if (old_message != nullptr && !old_message->is_content_changed) { return true;