Better handling of channelDifferenceTooLong.

GitOrigin-RevId: db70a044bf34c7e30b57266e361cd9579f864e39
This commit is contained in:
levlam 2018-11-21 16:08:37 +03:00
parent b666f554f4
commit f2a4cbd1f7

View File

@ -22098,9 +22098,6 @@ void MessagesManager::on_get_channel_dialog(DialogId dialog_id, MessageId last_m
}
return;
}
} else {
LOG(ERROR) << "Receive as last " << last_message_id;
return;
}
Dialog *d = get_dialog(dialog_id);
@ -22125,17 +22122,20 @@ void MessagesManager::on_get_channel_dialog(DialogId dialog_id, MessageId last_m
// offline. It is the best way for gaps support, but it is pretty hard to implement correctly.
// It should be also noted that some messages like live location messages shouldn't be deleted.
set_dialog_first_database_message_id(d, MessageId(), "on_get_channel_dialog");
set_dialog_last_database_message_id(d, MessageId(), "on_get_channel_dialog");
d->have_full_history = false;
for (auto &first_message_id : d->first_database_message_id_by_index) {
first_message_id = MessageId();
if (last_message_id.get() > d->last_new_message_id.get()) {
// TODO properly support last_message_id.get() <= d->last_new_message_id.get()
set_dialog_first_database_message_id(d, MessageId(), "on_get_channel_dialog");
set_dialog_last_database_message_id(d, MessageId(), "on_get_channel_dialog");
d->have_full_history = false;
for (auto &first_message_id : d->first_database_message_id_by_index) {
first_message_id = MessageId();
}
}
std::fill(d->message_count_by_index.begin(), d->message_count_by_index.end(), -1);
on_dialog_updated(dialog_id, "on_get_channel_dialog 10");
// TODO support last_message_id.get() < d->last_new_message_id.get()
// TODO properly support last_message_id.get() <= d->last_new_message_id.get()
if (last_message_id.get() > d->last_new_message_id.get()) { // if last message is really a new message
d->last_new_message_id = MessageId();
set_dialog_last_message_id(d, MessageId(), "on_get_channel_dialog 20");