From 4618d0611efeafc0f6e831945c43dce9426e87c4 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 13 Jan 2019 22:28:25 +0300 Subject: [PATCH] Fix CHECK. GitOrigin-RevId: 376b93e35f13c5637762c03a5a50013c6d4febed --- td/telegram/NotificationManager.cpp | 12 ++++++++++-- td/telegram/NotificationSettings.cpp | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index f261a4252..607845100 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -783,9 +783,17 @@ void NotificationManager::flush_pending_updates(int32 group_id, const char *sour for (auto ¬ification_id : update_ptr->removed_notification_ids_) { added_notification_ids.erase(notification_id); edited_notification_ids.erase(notification_id); - bool is_inserted = removed_notification_ids.insert(notification_id).second; - CHECK(is_inserted); // there must be no deletions after deletions + if (!removed_notification_ids.insert(notification_id).second) { + // sometimes there can be deletion of notification without previous addition, because the notification + // has already been deleted at the time of addition and get_notification_object_type was nullptr + VLOG(notifications) << "Remove duplicated deletion of " << notification_id; + notification_id = 0; + } } + update_ptr->removed_notification_ids_.erase( + std::remove_if(update_ptr->removed_notification_ids_.begin(), update_ptr->removed_notification_ids_.end(), + [](auto ¬ification_id) { return notification_id == 0; }), + update_ptr->removed_notification_ids_.end()); } else { CHECK(update->get_id() == td_api::updateNotification::ID); auto update_ptr = static_cast(update.get()); diff --git a/td/telegram/NotificationSettings.cpp b/td/telegram/NotificationSettings.cpp index 6ee2565f0..ec49d03fa 100644 --- a/td/telegram/NotificationSettings.cpp +++ b/td/telegram/NotificationSettings.cpp @@ -40,7 +40,7 @@ StringBuilder &operator<<(StringBuilder &string_builder, NotificationSettingsSco StringBuilder &operator<<(StringBuilder &string_builder, const ScopeNotificationSettings ¬ification_settings) { return string_builder << "[" << notification_settings.mute_until << ", " << notification_settings.sound << ", " << notification_settings.show_preview << ", " << notification_settings.is_synchronized << ", " - << notification_settings.disable_pinned_message_notifications + << notification_settings.disable_pinned_message_notifications << ", " << notification_settings.disable_mention_notifications << "]"; }