Move yet_unsent_message_id_to_persistent_message_id out of each Dialog.
This commit is contained in:
parent
5ee1c751f9
commit
78d5146188
@ -25952,15 +25952,15 @@ Status MessagesManager::can_send_message(DialogId dialog_id) const {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
MessageId MessagesManager::get_persistent_message_id(const Dialog *d, MessageId message_id) {
|
||||
MessageId MessagesManager::get_persistent_message_id(const Dialog *d, MessageId message_id) const {
|
||||
if (!message_id.is_valid() && !message_id.is_valid_scheduled()) {
|
||||
return MessageId();
|
||||
}
|
||||
if (message_id.is_yet_unsent()) {
|
||||
// it is possible that user tries to do something with an already sent message by its temporary identifier
|
||||
// we need to use real message in this case and transparently replace message_id
|
||||
auto it = d->yet_unsent_message_id_to_persistent_message_id.find(message_id);
|
||||
if (it != d->yet_unsent_message_id_to_persistent_message_id.end()) {
|
||||
auto it = yet_unsent_full_message_id_to_persistent_message_id_.find({d->dialog_id, message_id});
|
||||
if (it != yet_unsent_full_message_id_to_persistent_message_id_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
@ -31506,11 +31506,11 @@ void MessagesManager::remove_message_dialog_notifications(Dialog *d, MessageId m
|
||||
NotificationId(), max_notification_message_id, 0, true, Promise<Unit>());
|
||||
}
|
||||
|
||||
void MessagesManager::send_update_message_send_succeeded(Dialog *d, MessageId old_message_id, const Message *m) const {
|
||||
void MessagesManager::send_update_message_send_succeeded(const Dialog *d, MessageId old_message_id, const Message *m) {
|
||||
CHECK(m != nullptr);
|
||||
CHECK(d->is_update_new_chat_sent);
|
||||
if (!td_->auth_manager_->is_bot()) {
|
||||
d->yet_unsent_message_id_to_persistent_message_id.emplace(old_message_id, m->message_id);
|
||||
yet_unsent_full_message_id_to_persistent_message_id_.emplace({d->dialog_id, old_message_id}, m->message_id);
|
||||
}
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
make_tl_object<td_api::updateMessageSendSucceeded>(
|
||||
@ -32707,7 +32707,7 @@ void MessagesManager::fail_send_message(FullMessageId full_message_id, int error
|
||||
|
||||
LOG(INFO) << "Send updateMessageSendFailed for " << full_message_id;
|
||||
if (!td_->auth_manager_->is_bot()) {
|
||||
d->yet_unsent_message_id_to_persistent_message_id.emplace(old_message_id, m->message_id);
|
||||
yet_unsent_full_message_id_to_persistent_message_id_.emplace({dialog_id, old_message_id}, m->message_id);
|
||||
}
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
make_tl_object<td_api::updateMessageSendFailed>(get_message_object(dialog_id, m, "fail_send_message"),
|
||||
|
@ -1424,8 +1424,6 @@ class MessagesManager final : public Actor {
|
||||
|
||||
FlatHashMap<ScheduledServerMessageId, int32, ScheduledServerMessageIdHash> scheduled_message_date;
|
||||
|
||||
FlatHashMap<MessageId, MessageId, MessageIdHash> yet_unsent_message_id_to_persistent_message_id;
|
||||
|
||||
FlatHashMap<int32, MessageId> last_assigned_scheduled_message_id; // date -> message_id
|
||||
|
||||
WaitFreeHashSet<MessageId, MessageIdHash> deleted_message_ids;
|
||||
@ -1948,7 +1946,7 @@ class MessagesManager final : public Actor {
|
||||
bool was_uploaded, bool was_thumbnail_uploaded, string file_reference,
|
||||
int32 schedule_date, uint64 generation, Result<int32> &&result);
|
||||
|
||||
static MessageId get_persistent_message_id(const Dialog *d, MessageId message_id);
|
||||
MessageId get_persistent_message_id(const Dialog *d, MessageId message_id) const;
|
||||
|
||||
static FullMessageId get_replied_message_id(DialogId dialog_id, const Message *m);
|
||||
|
||||
@ -2502,7 +2500,7 @@ class MessagesManager final : public Actor {
|
||||
|
||||
bool need_skip_bot_commands(DialogId dialog_id, const Message *m) const;
|
||||
|
||||
void send_update_message_send_succeeded(Dialog *d, MessageId old_message_id, const Message *m) const;
|
||||
void send_update_message_send_succeeded(const Dialog *d, MessageId old_message_id, const Message *m);
|
||||
|
||||
void send_update_message_content(const Dialog *d, Message *m, bool is_message_in_dialog, const char *source);
|
||||
|
||||
@ -3756,6 +3754,8 @@ class MessagesManager final : public Actor {
|
||||
|
||||
FlatHashMap<DialogId, MessageId, DialogIdHash> previous_repaired_read_inbox_max_message_id_;
|
||||
|
||||
FlatHashMap<FullMessageId, MessageId, FullMessageIdHash> yet_unsent_full_message_id_to_persistent_message_id_;
|
||||
|
||||
struct PendingReaction {
|
||||
int32 query_count = 0;
|
||||
bool was_updated = false;
|
||||
|
Loading…
Reference in New Issue
Block a user