Fix pdateActiveNotifications.

GitOrigin-RevId: 94fa89e8b7313ad7716779726ab169bbb51474b1
This commit is contained in:
levlam 2019-03-31 18:27:35 +03:00
parent e5da6a5017
commit 1923170840
2 changed files with 6 additions and 1 deletions

View File

@ -29,6 +29,7 @@ class Notification {
inline td_api::object_ptr<td_api::notification> get_notification_object(DialogId dialog_id,
const Notification &notification) {
CHECK(notification.type != nullptr);
return td_api::make_object<td_api::notification>(notification.notification_id.get(), notification.date,
notification.type->get_notification_type_object(dialog_id));
}

View File

@ -324,13 +324,17 @@ td_api::object_ptr<td_api::updateActiveNotifications> NotificationManager::get_u
needed_groups--;
vector<td_api::object_ptr<td_api::notification>> notifications;
for (auto &notification : group.second.notifications) {
for (auto &notification : 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<td_api::notificationGroup>(
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)));