Fix race in get_message_notification_group_force.

GitOrigin-RevId: 7c75103e168f41b1964504f53d69cee85210d601
This commit is contained in:
levlam 2018-11-30 01:57:24 +03:00
parent a7e8bd166c
commit 9615604ecf
2 changed files with 9 additions and 4 deletions

View File

@ -17605,7 +17605,8 @@ MessagesManager::MessageNotificationGroup MessagesManager::get_message_notificat
result.dialog_id = d->dialog_id;
result.total_count = get_dialog_pending_notification_count(d);
result.notifications = get_message_notifications_from_database(
d, NotificationId::max(), td_->notification_manager_->get_max_notification_group_size());
d, d->first_new_notification_id.is_valid() ? d->first_new_notification_id : NotificationId::max(),
td_->notification_manager_->get_max_notification_group_size());
int32 last_notification_date = 0;
NotificationId last_notification_id;
@ -17857,6 +17858,9 @@ bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool f
add_notification_id_to_message_id_correspondence(d, m->notification_id, m->message_id);
}
bool is_changed = set_dialog_last_notification(d, m->date, m->notification_id, "add_new_message_notification");
if (!d->first_new_notification_id.is_valid()) {
d->first_new_notification_id = m->notification_id;
}
CHECK(is_changed);
VLOG(notifications) << "Create " << m->notification_id << " with " << m->message_id << " in " << d->dialog_id;
send_closure_later(G()->notification_manager(), &NotificationManager::add_notification,

View File

@ -883,9 +883,10 @@ class MessagesManager : public Actor {
MessageId max_added_message_id;
NotificationGroupId message_notification_group_id;
int32 last_notification_date = 0;
NotificationId last_notification_id;
NotificationId max_removed_notification_id;
int32 last_notification_date = 0; // last known date of last notification in the dialog
NotificationId last_notification_id; // last known identifier of last notification in the dialog
NotificationId max_removed_notification_id; // notification identifier, up to which all notifications are removed
NotificationId first_new_notification_id; // identifier of first added notification in that library launch
bool has_contact_registered_message = false;