From 01819827495096258f496c0baab7f7ba074b6a59 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 5 Jun 2019 03:14:54 +0300 Subject: [PATCH] Improve getting groups in common. GitOrigin-RevId: 211d8706823b9aa509af00855083a1981a0a963a --- td/telegram/ContactsManager.cpp | 4 ++++ td/telegram/MessagesManager.cpp | 7 ++++--- td/telegram/StickersManager.cpp | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 5001693a..dcf9e158 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -7123,6 +7123,10 @@ void ContactsManager::on_update_user_common_chat_count(UserId user_id, int32 com void ContactsManager::on_update_user_full_common_chat_count(UserFull *user_full, UserId user_id, int32 common_chat_count) { CHECK(user_full != nullptr); + if (common_chat_count < 0) { + LOG(ERROR) << "Receive " << common_chat_count << " as common group count with " << user_id; + common_chat_count = 0; + } if (user_full->is_inited && user_full->common_chat_count != common_chat_count) { user_full->common_chat_count = common_chat_count; user_full->is_common_chat_count_changed = true; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 6958f31a..0cf06aac 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -11876,6 +11876,7 @@ void MessagesManager::on_get_common_dialogs(UserId user_id, int32 offset_chat_id if (!result.empty() && result.back() == DialogId()) { return; } + bool is_last = chats.empty() && offset_chat_id == 0; for (auto &chat : chats) { DialogId dialog_id; switch (chat->get_id()) { @@ -11940,7 +11941,7 @@ void MessagesManager::on_get_common_dialogs(UserId user_id, int32 offset_chat_id result.push_back(dialog_id); } } - if (result.size() >= static_cast(total_count)) { + if (result.size() >= static_cast(total_count) || is_last) { result.push_back(DialogId()); } } @@ -23510,8 +23511,8 @@ bool MessagesManager::update_message(Dialog *d, unique_ptr &old_message old_type != MessageContentType::ExpiredPhoto && old_type != MessageContentType::ExpiredVideo) { LOG(ERROR) << message_id << " in " << dialog_id << " has changed contains_mention from " << old_message->contains_mention << " to " << new_message->contains_mention - << ", is_outgoing = " << old_message->is_outgoing << ", message content type is " - << old_type << '/' << new_message->content->get_type(); + << ", is_outgoing = " << old_message->is_outgoing << ", message content type is " << old_type << '/' + << new_message->content->get_type(); } // contains_mention flag shouldn't be changed, because the message will not be added to unread mention list // and we are unable to show/hide message notification diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 16c3252b..2656bef7 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -2896,7 +2896,8 @@ void StickersManager::on_get_archived_sticker_sets( // if 0 sticker sets are received then set offset_sticker_set_id was found and there is no stickers after it // or it wasn't found and there is no archived sets at all bool is_last = - sticker_sets.empty() && (offset_sticker_set_id == 0 || offset_sticker_set_id == sticker_set_ids.back()); + sticker_sets.empty() && + (offset_sticker_set_id == 0 || (!sticker_set_ids.empty() && offset_sticker_set_id == sticker_set_ids.back())); total_archived_sticker_set_count_[is_masks] = total_count; for (auto &sticker_set_covered : sticker_sets) {