Improve get_next_message_id.

GitOrigin-RevId: af978d83a85415439a6168964e7f05335c16b76d
This commit is contained in:
levlam 2018-08-05 00:05:29 +03:00
parent b97570b817
commit 72d2235f6e
2 changed files with 10 additions and 3 deletions

View File

@ -20430,9 +20430,10 @@ void MessagesManager::on_send_message_fail(int64 random_id, Status error) {
MessageId MessagesManager::get_next_message_id(Dialog *d, int32 type) {
CHECK(d != nullptr);
int64 last = std::max({d->last_message_id.get(), d->last_new_message_id.get(), d->last_database_message_id.get(),
int64 last =
std::max({d->last_message_id.get(), d->last_new_message_id.get(), d->last_database_message_id.get(),
d->last_assigned_message_id.get(), d->last_clear_history_message_id.get(),
d->deleted_last_message_id.get(), d->max_unavailable_message_id.get()});
d->deleted_last_message_id.get(), d->max_unavailable_message_id.get(), d->max_added_message_id.get()});
if (last < d->last_read_inbox_message_id.get() &&
d->last_read_inbox_message_id.get() < d->last_new_message_id.get() + MessageId::FULL_TYPE_MASK) {
last = d->last_read_inbox_message_id.get();
@ -23381,6 +23382,10 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
}
}
if (message->message_id.get() > d->max_added_message_id.get()) {
d->max_added_message_id = message->message_id;
}
if (d->have_full_history && !message->from_database && !from_update && !message_id.is_local() &&
!message_id.is_yet_unsent()) {
LOG(ERROR) << "Have full history in " << dialog_id << ", but receive unknown " << message_id

View File

@ -1626,6 +1626,8 @@ class MessagesManager : public Actor {
int32 delete_last_message_date = 0;
MessageId deleted_last_message_id;
MessageId max_added_message_id;
bool has_contact_registered_message = false;
bool is_last_message_deleted_locally = false;