Apply postponed channel updates even Dialog wasn't created.

This commit is contained in:
levlam 2021-07-30 04:56:39 +03:00
parent 50052f63ef
commit ed15c1078b

View File

@ -35864,9 +35864,8 @@ void MessagesManager::after_get_channel_difference(DialogId dialog_id, bool succ
}
auto d = get_dialog(dialog_id);
if (d != nullptr) {
d->is_channel_difference_finished = true;
bool have_access = have_input_peer(dialog_id, AccessRights::Read);
auto pts = d != nullptr ? d->pts : load_channel_pts(dialog_id);
auto updates_it = postponed_channel_updates_.find(dialog_id);
if (updates_it != postponed_channel_updates_.end()) {
auto &updates = updates_it->second;
@ -35888,14 +35887,14 @@ void MessagesManager::after_get_channel_difference(DialogId dialog_id, bool succ
promise.set_value(Unit());
}
if (updates.size() != old_size || running_get_channel_difference(dialog_id)) {
if (success && update_pts - 10000 < d->pts && update_pts_count == 1) {
if (success && update_pts - 10000 < pts && update_pts_count == 1) {
// if getChannelDifference was successful and update pts is near channel pts,
// we hope that the update eventually can be applied
LOG(INFO) << "Can't apply postponed channel updates";
} else {
// otherwise protect from getChannelDifference repeating calls by dropping postponed updates
LOG(WARNING) << "Failed to apply postponed updates of type " << update_id << " in " << dialog_id
<< " with pts " << d->pts << ", update pts is " << update_pts << ", update pts count is "
<< " with pts " << pts << ", update pts is " << update_pts << ", update pts count is "
<< update_pts_count;
vector<Promise<Unit>> update_promises;
for (auto &postponed_update : updates) {
@ -35915,6 +35914,9 @@ void MessagesManager::after_get_channel_difference(DialogId dialog_id, bool succ
LOG(INFO) << "Finish to apply postponed channel updates";
}
if (d != nullptr) {
d->is_channel_difference_finished = true;
if (d->message_notification_group.group_id.is_valid()) {
send_closure_later(G()->notification_manager(), &NotificationManager::after_get_chat_difference,
d->message_notification_group.group_id);