From 1923170840df9a2f707ea8db699fd45ec5512f8b Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 31 Mar 2019 18:27:35 +0300 Subject: [PATCH] Fix pdateActiveNotifications. GitOrigin-RevId: 94fa89e8b7313ad7716779726ab169bbb51474b1 --- td/telegram/Notification.h | 1 + td/telegram/NotificationManager.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/td/telegram/Notification.h b/td/telegram/Notification.h index 45c48117..325f8f3e 100644 --- a/td/telegram/Notification.h +++ b/td/telegram/Notification.h @@ -29,6 +29,7 @@ class Notification { inline td_api::object_ptr get_notification_object(DialogId dialog_id, const Notification ¬ification) { + CHECK(notification.type != nullptr); return td_api::make_object(notification.notification_id.get(), notification.date, notification.type->get_notification_type_object(dialog_id)); } diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index 0ba5011b..8745023a 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -324,13 +324,17 @@ td_api::object_ptr NotificationManager::get_u needed_groups--; vector> notifications; - for (auto ¬ification : group.second.notifications) { + for (auto ¬ification : reversed(group.second.notifications)) { auto notification_object = get_notification_object(group.first.dialog_id, notification); if (notification_object->type_ != nullptr) { notifications.push_back(std::move(notification_object)); } + if (notifications.size() == max_notification_group_size_) { + break; + } } if (!notifications.empty()) { + std::reverse(notifications.begin(), notifications.end()); groups.push_back(td_api::make_object( group.first.group_id.get(), get_notification_group_type_object(group.second.type), group.first.dialog_id.get(), group.second.total_count, std::move(notifications)));