Fix creating postponed getMessage requests for pinned message.
GitOrigin-RevId: 8f5136516ef01962e52d72c14bc4f6bb58e8de75
This commit is contained in:
parent
80edd0b059
commit
a7a3d3c135
@ -11756,8 +11756,11 @@ void MessagesManager::get_message_force_from_server(Dialog *d, MessageId message
|
||||
// message will not be added to the dialog anyway
|
||||
if (dialog_type == DialogType::Channel) {
|
||||
// so we try to force channel difference first
|
||||
CHECK(input_message == nullptr); // replied message can't be older than already added original message
|
||||
postponed_get_message_requests_[d->dialog_id].emplace_back(message_id, std::move(promise));
|
||||
|
||||
// replied message can't be older than already added original message, but pinned message can be
|
||||
CHECK(input_message == nullptr || input_message->get_id() == telegram_api::inputMessagePinned::ID);
|
||||
postponed_get_message_requests_[d->dialog_id].emplace_back(message_id, std::move(promise),
|
||||
std::move(input_message));
|
||||
get_channel_difference(d->dialog_id, d->pts, true, "get_message");
|
||||
} else {
|
||||
promise.set_value(Unit());
|
||||
@ -24204,13 +24207,13 @@ void MessagesManager::after_get_channel_difference(DialogId dialog_id, bool succ
|
||||
if (it_get_message_requests != postponed_get_message_requests_.end()) {
|
||||
CHECK(d != nullptr);
|
||||
for (auto &request : it_get_message_requests->second) {
|
||||
auto message_id = request.first;
|
||||
auto message_id = request.message_id;
|
||||
LOG(INFO) << "Run postponed getMessage request for " << message_id << " in " << dialog_id;
|
||||
if (d->last_new_message_id != MessageId() && message_id.get() > d->last_new_message_id.get()) {
|
||||
// message will not be added to the dialog anyway, get channel difference didn't help
|
||||
request.second.set_value(Unit());
|
||||
request.promise.set_value(Unit());
|
||||
} else {
|
||||
get_message_from_server({dialog_id, message_id}, std::move(request.second));
|
||||
get_message_from_server({dialog_id, message_id}, std::move(request.promise), std::move(request.input_message));
|
||||
}
|
||||
}
|
||||
postponed_get_message_requests_.erase(it_get_message_requests);
|
||||
|
@ -2201,8 +2201,19 @@ class MessagesManager : public Actor {
|
||||
loaded_dialogs_; // dialogs loaded from database, but not added to dialogs_
|
||||
|
||||
std::unordered_set<DialogId, DialogIdHash> postponed_chat_read_inbox_updates_;
|
||||
std::unordered_map<DialogId, vector<std::pair<MessageId, Promise<Unit>>>, DialogIdHash>
|
||||
postponed_get_message_requests_;
|
||||
|
||||
struct PendingGetMessageRequest {
|
||||
MessageId message_id;
|
||||
Promise<Unit> promise;
|
||||
tl_object_ptr<telegram_api::InputMessage> input_message;
|
||||
|
||||
PendingGetMessageRequest(MessageId message_id, Promise<Unit> promise,
|
||||
tl_object_ptr<telegram_api::InputMessage> input_message)
|
||||
: message_id(message_id), promise(std::move(promise)), input_message(std::move(input_message)) {
|
||||
}
|
||||
};
|
||||
|
||||
std::unordered_map<DialogId, vector<PendingGetMessageRequest>, DialogIdHash> postponed_get_message_requests_;
|
||||
|
||||
std::unordered_map<string, vector<Promise<Unit>>> search_public_dialogs_queries_;
|
||||
std::unordered_map<string, vector<DialogId>> found_public_dialogs_; // TODO time bound cache
|
||||
|
Reference in New Issue
Block a user