Fix CHECK.

GitOrigin-RevId: 376b93e35f13c5637762c03a5a50013c6d4febed
This commit is contained in:
levlam 2019-01-13 22:28:25 +03:00
parent 7cead9fc0f
commit 4618d0611e
2 changed files with 11 additions and 3 deletions

View File

@ -783,9 +783,17 @@ void NotificationManager::flush_pending_updates(int32 group_id, const char *sour
for (auto &notification_id : update_ptr->removed_notification_ids_) { for (auto &notification_id : update_ptr->removed_notification_ids_) {
added_notification_ids.erase(notification_id); added_notification_ids.erase(notification_id);
edited_notification_ids.erase(notification_id); edited_notification_ids.erase(notification_id);
bool is_inserted = removed_notification_ids.insert(notification_id).second; if (!removed_notification_ids.insert(notification_id).second) {
CHECK(is_inserted); // there must be no deletions after deletions // 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 &notification_id) { return notification_id == 0; }),
update_ptr->removed_notification_ids_.end());
} else { } else {
CHECK(update->get_id() == td_api::updateNotification::ID); CHECK(update->get_id() == td_api::updateNotification::ID);
auto update_ptr = static_cast<td_api::updateNotification *>(update.get()); auto update_ptr = static_cast<td_api::updateNotification *>(update.get());

View File

@ -40,7 +40,7 @@ StringBuilder &operator<<(StringBuilder &string_builder, NotificationSettingsSco
StringBuilder &operator<<(StringBuilder &string_builder, const ScopeNotificationSettings &notification_settings) { StringBuilder &operator<<(StringBuilder &string_builder, const ScopeNotificationSettings &notification_settings) {
return string_builder << "[" << notification_settings.mute_until << ", " << notification_settings.sound << ", " return string_builder << "[" << notification_settings.mute_until << ", " << notification_settings.sound << ", "
<< notification_settings.show_preview << ", " << notification_settings.is_synchronized << ", " << 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 << "]"; << notification_settings.disable_mention_notifications << "]";
} }