Support business messages in need_skip_update_message.

This commit is contained in:
levlam 2024-03-18 11:54:29 +03:00
parent f6497b76c4
commit b9d4d57678

View File

@ -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<td_api::message> &message, bool is_edited) const { bool Client::need_skip_update_message(int64 chat_id, const object_ptr<td_api::message> &message, bool is_edited) const {
auto chat = get_chat(chat_id); const ChatInfo *chat;
CHECK(chat != nullptr); ChatInfo::Type chat_type;
if (message->is_outgoing_) { 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()) { switch (message->content_->get_id()) {
case td_api::messageChatChangeTitle::ID: case td_api::messageChatChangeTitle::ID:
case td_api::messageChatChangePhoto::ID: case td_api::messageChatChangePhoto::ID:
@ -12600,7 +12608,8 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptr<td_api::me
return true; return true;
} }
if (chat->type == ChatInfo::Type::Supergroup) { if (chat_type == ChatInfo::Type::Supergroup) {
CHECK(chat != nullptr);
auto supergroup_info = get_supergroup_info(chat->supergroup_id); auto supergroup_info = get_supergroup_info(chat->supergroup_id);
if (supergroup_info->status->get_id() == td_api::chatMemberStatusLeft::ID || if (supergroup_info->status->get_id() == td_api::chatMemberStatusLeft::ID ||
supergroup_info->status->get_id() == td_api::chatMemberStatusBanned::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_ptr<td_api::me
break; break;
} }
case td_api::messageSupergroupChatCreate::ID: { case td_api::messageSupergroupChatCreate::ID: {
if (chat->type != ChatInfo::Type::Supergroup) { if (chat_type != ChatInfo::Type::Supergroup) {
LOG(ERROR) << "Receive messageSupergroupChatCreate in the non-supergroup chat " << chat_id; LOG(ERROR) << "Receive messageSupergroupChatCreate in the non-supergroup chat " << chat_id;
return true; return true;
} }
@ -12698,7 +12707,7 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptr<td_api::me
break; break;
} }
if (is_edited) { if (is_edited && chat_id != 0) {
const MessageInfo *old_message = get_message(chat_id, message->id_, true); const MessageInfo *old_message = get_message(chat_id, message->id_, true);
if (old_message != nullptr && !old_message->is_content_changed) { if (old_message != nullptr && !old_message->is_content_changed) {
return true; return true;