Possibly fix random_id_to_message_id correspondence.

GitOrigin-RevId: 279fc911a03342796a2200b1edad5f27726be5fd
This commit is contained in:
levlam 2018-10-24 22:53:31 +03:00
parent 043602bfc2
commit 923cf40de6

View File

@ -10190,14 +10190,20 @@ void MessagesManager::add_random_id_to_message_id_correspondence(Dialog *d, int6
CHECK(d != nullptr);
CHECK(d->dialog_id.get_type() == DialogType::SecretChat);
LOG(INFO) << "Add correspondence from random_id " << random_id << " to " << message_id << " in " << d->dialog_id;
d->random_id_to_message_id[random_id] = message_id;
auto it = d->random_id_to_message_id.find(random_id);
if (it == d->random_id_to_message_id.end() || it->second.get() < message_id.get()) {
d->random_id_to_message_id[random_id] = message_id;
}
}
void MessagesManager::delete_random_id_to_message_id_correspondence(Dialog *d, int64 random_id, MessageId message_id) {
CHECK(d != nullptr);
CHECK(d->dialog_id.get_type() == DialogType::SecretChat);
LOG(INFO) << "Delete correspondence from random_id " << random_id << " to " << message_id << " in " << d->dialog_id;
d->random_id_to_message_id.erase(random_id);
auto it = d->random_id_to_message_id.find(random_id);
if (it != d->random_id_to_message_id.end() && it->second == message_id) {
d->random_id_to_message_id.erase(it);
}
}
// DO NOT FORGET TO ADD ALL CHANGES OF THIS FUNCTION AS WELL TO do_delete_all_dialog_messages