Store scheduled message date by their server message ID.

GitOrigin-RevId: de3ea20ea659ce9cf620e7223375937c494699a1
This commit is contained in:
levlam 2019-12-01 20:50:52 +03:00
parent 039db3374a
commit 9b7d248518
3 changed files with 20 additions and 0 deletions

View File

@ -12398,6 +12398,11 @@ unique_ptr<MessagesManager::Message> MessagesManager::do_delete_scheduled_messag
auto result = treap_delete_message(v);
if (message_id.is_scheduled_server()) {
size_t erased = d->scheduled_message_date.erase(message_id.get_scheduled_server_message_id());
CHECK(erased != 0);
}
cancel_send_deleted_message(d->dialog_id, result.get());
return nullptr;
@ -25426,6 +25431,12 @@ MessagesManager::Message *MessagesManager::add_scheduled_message_to_dialog(Dialo
update_used_hashtags(dialog_id, m);
}
if (message_id.is_scheduled_server()) {
int32 &date = d->scheduled_message_date[message_id.get_scheduled_server_message_id()];
CHECK(date == 0);
date = m->date;
}
Message *result_message = treap_insert_message(&d->scheduled_messages, std::move(message));
CHECK(result_message != nullptr);
CHECK(d->scheduled_messages != nullptr);

View File

@ -1103,6 +1103,8 @@ class MessagesManager : public Actor {
// application start, used to guarantee that all assigned message identifiers
// are different
std::unordered_map<ScheduledServerMessageId, int32, ScheduledServerMessageIdHash> scheduled_message_date;
std::unordered_map<MessageId, MessageId, MessageIdHash> yet_unsent_message_id_to_persistent_message_id;
std::unordered_set<MessageId, MessageIdHash> deleted_message_ids;

View File

@ -8,6 +8,7 @@
#include "td/utils/common.h"
#include <functional>
#include <type_traits>
namespace td {
@ -50,4 +51,10 @@ class ScheduledServerMessageId {
}
};
struct ScheduledServerMessageIdHash {
std::size_t operator()(ScheduledServerMessageId message_id) const {
return std::hash<int32>()(message_id.get());
}
};
} // namespace td