Check notification message_id before allowing to edit it.

GitOrigin-RevId: f6713e719daa2058996ffe7ee4aad2299a03236d
This commit is contained in:
levlam 2019-06-17 18:54:35 +03:00
parent 0a0b875a27
commit 2ec992b106
1 changed files with 12 additions and 0 deletions

View File

@ -1622,6 +1622,12 @@ void NotificationManager::edit_notification(NotificationGroupId group_id, Notifi
for (size_t i = 0; i < group.notifications.size(); i++) {
auto &notification = group.notifications[i];
if (notification.notification_id == notification_id) {
if (notification.type->get_message_id() != type->get_message_id()) {
LOG(ERROR) << "Ignore edit of " << notification_id << " with " << *type << ", because previous type is "
<< *notification.type;
return;
}
notification.type = std::move(type);
if (i + max_notification_group_size_ >= group.notifications.size() &&
!(get_last_updated_group_key() < group_it->first)) {
@ -1633,6 +1639,12 @@ void NotificationManager::edit_notification(NotificationGroupId group_id, Notifi
}
for (auto &notification : group.pending_notifications) {
if (notification.notification_id == notification_id) {
if (notification.type->get_message_id() != type->get_message_id()) {
LOG(ERROR) << "Ignore edit of " << notification_id << " with " << *type << ", because previous type is "
<< *notification.type;
return;
}
notification.type = std::move(type);
return;
}