Store MessageFullId in replied_yet_unsent_messages_.

This commit is contained in:
levlam 2023-10-25 03:02:26 +03:00
parent f0382d8789
commit 87f7cdd69f
2 changed files with 15 additions and 14 deletions

View File

@ -24580,7 +24580,7 @@ void MessagesManager::cancel_send_message_query(DialogId dialog_id, Message *m)
CHECK(m->reply_in_dialog_id == DialogId());
auto it = replied_yet_unsent_messages_.find({dialog_id, m->reply_to_message_id});
CHECK(it != replied_yet_unsent_messages_.end());
size_t erased_count = it->second.erase(m->message_id);
size_t erased_count = it->second.erase({dialog_id, m->message_id});
CHECK(erased_count > 0);
if (it->second.empty()) {
replied_yet_unsent_messages_.erase(it);
@ -24589,12 +24589,13 @@ void MessagesManager::cancel_send_message_query(DialogId dialog_id, Message *m)
{
auto it = replied_yet_unsent_messages_.find({dialog_id, m->message_id});
if (it != replied_yet_unsent_messages_.end()) {
Dialog *d = get_dialog(dialog_id);
for (auto message_id : it->second) {
auto replied_m = get_message(d, message_id);
for (auto message_full_id : it->second) {
auto reply_d = get_dialog(message_full_id.get_dialog_id());
CHECK(reply_d != nullptr);
auto replied_m = get_message(reply_d, message_full_id.get_message_id());
CHECK(replied_m != nullptr);
CHECK(replied_m->reply_to_message_id == m->message_id);
set_message_reply(d, replied_m, replied_m->top_thread_message_id, true);
set_message_reply(reply_d, replied_m, replied_m->top_thread_message_id, true);
}
replied_yet_unsent_messages_.erase(it);
}
@ -30644,15 +30645,14 @@ void MessagesManager::update_reply_to_message_id(DialogId dialog_id, MessageId o
}
CHECK(old_message_id.is_yet_unsent());
Dialog *d = get_dialog(dialog_id);
for (auto message_id : it->second) {
CHECK(message_id.is_yet_unsent());
MessageFullId message_full_id{dialog_id, message_id};
auto replied_m = get_message(d, message_id);
for (auto message_full_id : it->second) {
auto reply_d = get_dialog(message_full_id.get_dialog_id());
CHECK(reply_d != nullptr);
auto replied_m = get_message(reply_d, message_full_id.get_message_id());
CHECK(replied_m != nullptr);
CHECK(replied_m->reply_to_message_id == old_message_id);
CHECK(replied_m->reply_in_dialog_id == DialogId());
set_message_reply(d, replied_m, new_message_id, true);
set_message_reply(reply_d, replied_m, new_message_id, true);
// TODO rewrite send message log event
}
if (have_new_message) {
@ -34762,7 +34762,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
replied_by_yet_unsent_messages_[MessageFullId{dialog_id, m->reply_to_message_id}]++;
}
} else {
replied_yet_unsent_messages_[MessageFullId{dialog_id, m->reply_to_message_id}].insert(m->message_id);
replied_yet_unsent_messages_[MessageFullId{dialog_id, m->reply_to_message_id}].insert({dialog_id, m->message_id});
}
}
@ -35016,7 +35016,7 @@ MessagesManager::Message *MessagesManager::add_scheduled_message_to_dialog(Dialo
replied_by_yet_unsent_messages_[MessageFullId{dialog_id, m->reply_to_message_id}]++;
}
} else {
replied_yet_unsent_messages_[MessageFullId{dialog_id, m->reply_to_message_id}].insert(m->message_id);
replied_yet_unsent_messages_[MessageFullId{dialog_id, m->reply_to_message_id}].insert({dialog_id, m->message_id});
}
}

View File

@ -3426,7 +3426,8 @@ class MessagesManager final : public Actor {
FlatHashMap<DialogId, uint64, DialogIdHash> get_dialog_query_log_event_id_;
FlatHashMap<MessageFullId, int32, MessageFullIdHash> replied_by_yet_unsent_messages_;
FlatHashMap<MessageFullId, FlatHashSet<MessageId, MessageIdHash>, MessageFullIdHash> replied_yet_unsent_messages_;
FlatHashMap<MessageFullId, FlatHashSet<MessageFullId, MessageFullIdHash>, MessageFullIdHash>
replied_yet_unsent_messages_;
// message_full_id -> replies with media timestamps
FlatHashMap<MessageFullId, FlatHashSet<MessageFullId, MessageFullIdHash>, MessageFullIdHash>