From 85352135fc2d213a472b2d22db7969f69ed0c7ff Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 29 Nov 2018 01:20:20 +0300 Subject: [PATCH] Repairing wrong last_notification_id. GitOrigin-RevId: f45d3806ea0c6ca38fd7f3c6b820f8f52255edf3 --- td/telegram/MessagesManager.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 0d075cee1..18368a82e 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -17462,6 +17462,16 @@ MessagesManager::MessageNotificationGroup MessagesManager::get_message_notificat result.total_count = get_dialog_pending_notification_count(d); result.notifications = get_message_notifications_from_database( d, NotificationId::max(), td_->notification_manager_->get_max_notification_group_size()); + + int32 last_notification_date = 0; + if (!result.notifications.empty()) { + last_notification_date = result.notifications[0].date; + } + if (last_notification_date != d->last_notification_date) { + LOG(ERROR) << "Fix last notification date in " << d->dialog_id << " from " << d->last_notification_date << " to " + << last_notification_date; + set_dialog_last_notification_date(d, last_notification_date); + } } return result; @@ -17486,7 +17496,8 @@ vector MessagesManager::get_message_notifications_from_database(Di res.reserve(messages.size()); for (auto &message : messages) { auto m = on_get_message_from_database(d->dialog_id, d, std::move(message)); - if (m != nullptr && m->notification_id.is_valid()) { + if (m != nullptr && m->notification_id.is_valid() && + (m->message_id.get() > d->last_read_inbox_message_id.get() || m->contains_unread_mention)) { res.emplace_back(m->notification_id, m->date, create_new_message_notification(m->message_id)); } }