From 0147c97f9c6035819e4df6f28bc18dcd8e00bcf0 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 17 Jul 2022 14:17:22 +0300 Subject: [PATCH] Ensure that the same notification doesn't added and removed simultaneously. --- td/telegram/NotificationManager.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index 85cc37766..d9de73483 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -980,6 +980,17 @@ void NotificationManager::add_update_notification_group(td_api::object_ptrnotification_settings_chat_id_ == 0) { update->notification_settings_chat_id_ = update->chat_id_; } + if (!update->added_notifications_.empty() && !update->removed_notification_ids_.empty()) { + // just in case + td::remove_if(update->added_notifications_, [&](const td_api::object_ptr ¬ification) { + CHECK(notification != nullptr); + if (td::contains(update->removed_notification_ids_, notification->id_)) { + LOG(ERROR) << "Have the same notification as added and removed"; + return true; + } + return false; + }); + } add_update(group_id, std::move(update)); }