Simplify adding message to dialog.

GitOrigin-RevId: c0cca65a5deafd763c215030c7dc82e92951b406
This commit is contained in:
levlam 2018-11-22 21:08:26 +03:00
parent 0362a95b7a
commit 9118cbc71c

View File

@ -20000,11 +20000,6 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
return nullptr;
}
if (!message->from_database) {
// load message from database before updating it
get_message_force(d, message_id);
}
if (message->reply_markup != nullptr &&
(message->reply_markup->type == ReplyMarkup::Type::RemoveKeyboard ||
(message->reply_markup->type == ReplyMarkup::Type::ForceReply && !message->reply_markup->is_personal)) &&
@ -20026,12 +20021,16 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
}
{
// TODO function
unique_ptr<Message> *v = &d->messages;
while (*v != nullptr && (*v)->random_y >= message->random_y) {
if ((*v)->message_id.get() < message_id.get()) {
v = &(*v)->right;
} else if ((*v)->message_id == message_id) {
unique_ptr<Message> *v = find_message(&d->messages, message_id);
if (*v == nullptr && !message->from_database) {
// load message from database before updating it
if (G()->parameters().use_message_db && get_message_force(d, message_id) != nullptr) {
v = find_message(&d->messages, message_id);
CHECK(*v != nullptr);
}
}
if (*v != nullptr) {
LOG(INFO) << "Adding already existing " << message_id << " in " << dialog_id << " from " << source;
if (*need_update) {
*need_update = false;
@ -20039,8 +20038,8 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
LOG(ERROR) << "Receive again " << (message->is_outgoing ? "outgoing" : "incoming")
<< (message->forward_info == nullptr ? " not" : "") << " forwarded " << message_id
<< " with content of type " << message_content_type << " in " << dialog_id << " from " << source
<< ", current last new is " << d->last_new_message_id << ", last is " << d->last_message_id
<< ". " << td_->updates_manager_->get_state();
<< ", current last new is " << d->last_new_message_id << ", last is " << d->last_message_id << ". "
<< td_->updates_manager_->get_state();
dump_debug_message_op(d, 1);
}
}
@ -20065,9 +20064,6 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
}
}
return v->get();
} else {
v = &(*v)->left;
}
}
}