Fix deletion of temporary message pusn notification by MESSAGE_DELETED.

GitOrigin-RevId: aaa259568e10ddfa58f8f0499cca0ebc49eae5d3
This commit is contained in:
levlam 2019-04-08 03:04:05 +03:00
parent 2082c09757
commit de87ddb108
3 changed files with 11 additions and 5 deletions

View File

@ -10306,7 +10306,7 @@ void MessagesManager::set_dialog_pinned_message_notification(Dialog *d, MessageI
on_message_changed(d, m, false, "set_dialog_pinned_message_notification");
} else {
send_closure_later(G()->notification_manager(), &NotificationManager::remove_temporary_notification_by_message_id,
d->mention_notification_group.group_id, old_message_id);
d->mention_notification_group.group_id, old_message_id, false);
}
}
d->pinned_message_notification_message_id = message_id;
@ -19046,6 +19046,11 @@ void MessagesManager::remove_message_notifications_by_message_ids(DialogId dialo
delete_message(d, message_id, true, &need_update_dialog_pos, "remove_message_notifications_by_message_ids");
if (m == nullptr) {
LOG(INFO) << "Can't delete " << message_id << " because it is not found";
// call synchronously to remove them before ProcessPush returns
td_->notification_manager_->remove_temporary_notification_by_message_id(d->message_notification_group.group_id,
message_id, true);
td_->notification_manager_->remove_temporary_notification_by_message_id(d->mention_notification_group.group_id,
message_id, true);
continue;
}
deleted_message_ids.push_back(m->message_id.get());

View File

@ -1872,7 +1872,7 @@ void NotificationManager::remove_notification(NotificationGroupId group_id, Noti
}
void NotificationManager::remove_temporary_notification_by_message_id(NotificationGroupId group_id,
MessageId message_id) {
MessageId message_id, bool force_update) {
if (!group_id.is_valid()) {
return;
}
@ -1887,12 +1887,12 @@ void NotificationManager::remove_temporary_notification_by_message_id(Notificati
for (auto &notification : group_it->second.pending_notifications) {
if (notification.type->get_message_id() == message_id) {
return remove_notification(group_id, notification.notification_id, true, false, Auto());
return remove_notification(group_id, notification.notification_id, true, force_update, Auto());
}
}
for (auto &notification : group_it->second.notifications) {
if (notification.type->get_message_id() == message_id) {
return remove_notification(group_id, notification.notification_id, true, false, Auto());
return remove_notification(group_id, notification.notification_id, true, force_update, Auto());
}
}
}

View File

@ -73,7 +73,8 @@ class NotificationManager : public Actor {
void remove_notification(NotificationGroupId group_id, NotificationId notification_id, bool is_permanent,
bool force_update, Promise<Unit> &&promise);
void remove_temporary_notification_by_message_id(NotificationGroupId group_id, MessageId message_id);
void remove_temporary_notification_by_message_id(NotificationGroupId group_id, MessageId message_id,
bool force_update);
void remove_notification_group(NotificationGroupId group_id, NotificationId max_notification_id,
MessageId max_message_id, int32 new_total_count, bool force_update,