Add get_message_from_server proxy-method.

GitOrigin-RevId: 02673a150241dc428c4161f87b5dd0651984c4a9
This commit is contained in:
levlam 2019-02-21 22:28:53 +03:00
parent 86f4ff2559
commit 4a4c8bd534
4 changed files with 21 additions and 15 deletions

View File

@ -79,8 +79,7 @@ class GetBotCallbackAnswerQuery : public Td::ResultHandler {
void on_error(uint64 id, Status status) override { void on_error(uint64 id, Status status) override {
if (status.message() == "DATA_INVALID") { if (status.message() == "DATA_INVALID") {
td->messages_manager_->get_messages_from_server(vector<FullMessageId>{FullMessageId{dialog_id_, message_id_}}, td->messages_manager_->get_message_from_server({dialog_id_, message_id_}, Auto());
Auto());
} }
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetBotCallbackAnswerQuery"); td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetBotCallbackAnswerQuery");
td->callback_queries_manager_->on_get_callback_query_answer(result_id_, nullptr); td->callback_queries_manager_->on_get_callback_query_answer(result_id_, nullptr);

View File

@ -40,7 +40,7 @@ size_t FileReferenceManager::get_file_reference_error_pos(const Status &error) {
} }
/* /*
fileSourceMessage chat_id:int53 message_id:int53 = FileSource; // repaired with get_messages_from_server fileSourceMessage chat_id:int53 message_id:int53 = FileSource; // repaired with get_message_from_server
fileSourceUserProfilePhoto user_id:int32 photo_id:int64 = FileSource; // repaired with photos.getUserPhotos fileSourceUserProfilePhoto user_id:int32 photo_id:int64 = FileSource; // repaired with photos.getUserPhotos
fileSourceBasicGroupPhoto basic_group_id:int32 = FileSource; // repaired with messages.getChats fileSourceBasicGroupPhoto basic_group_id:int32 = FileSource; // repaired with messages.getChats
fileSourceSupergroupPhoto supergroup_id:int32 = FileSource; // repaired with channels.getChannels fileSourceSupergroupPhoto supergroup_id:int32 = FileSource; // repaired with channels.getChannels
@ -236,8 +236,8 @@ void FileReferenceManager::send_query(Destination dest, FileSourceId file_source
CHECK(index < file_sources_.size()); CHECK(index < file_sources_.size());
file_sources_[index].visit(overloaded( file_sources_[index].visit(overloaded(
[&](const FileSourceMessage &source) { [&](const FileSourceMessage &source) {
send_closure_later(G()->messages_manager(), &MessagesManager::get_messages_from_server, send_closure_later(G()->messages_manager(), &MessagesManager::get_message_from_server, source.full_message_id,
vector<FullMessageId>{source.full_message_id}, std::move(promise), nullptr); std::move(promise), nullptr);
}, },
[&](const FileSourceUserPhoto &source) { [&](const FileSourceUserPhoto &source) {
send_closure_later(G()->contacts_manager(), &ContactsManager::reload_user_profile_photo, source.user_id, send_closure_later(G()->contacts_manager(), &ContactsManager::reload_user_profile_photo, source.user_id,

View File

@ -6517,8 +6517,8 @@ void MessagesManager::after_get_difference() {
if (dialog_id.get_type() != DialogType::Channel) { if (dialog_id.get_type() != DialogType::Channel) {
dump_debug_message_op(get_dialog(dialog_id)); dump_debug_message_op(get_dialog(dialog_id));
} }
get_messages_from_server( get_message_from_server(
{it.first}, PromiseCreator::lambda([this, full_message_id = it.first](Result<Unit> result) { it.first, PromiseCreator::lambda([this, full_message_id = it.first](Result<Unit> result) {
if (result.is_error()) { if (result.is_error()) {
LOG(WARNING) << "Failed to get missing " << full_message_id << ": " << result.error(); LOG(WARNING) << "Failed to get missing " << full_message_id << ": " << result.error();
} else { } else {
@ -11610,8 +11610,7 @@ void MessagesManager::get_message_force_from_server(Dialog *d, MessageId message
} }
if (d->deleted_message_ids.count(message_id) == 0 && dialog_type != DialogType::SecretChat) { if (d->deleted_message_ids.count(message_id) == 0 && dialog_type != DialogType::SecretChat) {
return get_messages_from_server({FullMessageId(d->dialog_id, message_id)}, std::move(promise), return get_message_from_server({d->dialog_id, message_id}, std::move(promise), std::move(input_message));
std::move(input_message));
} }
} }
@ -11732,6 +11731,11 @@ bool MessagesManager::get_messages(DialogId dialog_id, const vector<MessageId> &
return true; return true;
} }
void MessagesManager::get_message_from_server(FullMessageId full_message_id, Promise<Unit> &&promise,
tl_object_ptr<telegram_api::InputMessage> input_message) {
get_messages_from_server({full_message_id}, std::move(promise), std::move(input_message));
}
void MessagesManager::get_messages_from_server(vector<FullMessageId> &&message_ids, Promise<Unit> &&promise, void MessagesManager::get_messages_from_server(vector<FullMessageId> &&message_ids, Promise<Unit> &&promise,
tl_object_ptr<telegram_api::InputMessage> input_message) { tl_object_ptr<telegram_api::InputMessage> input_message) {
if (message_ids.empty()) { if (message_ids.empty()) {
@ -14372,7 +14376,7 @@ unique_ptr<MessagesManager::Message> MessagesManager::parse_message(DialogId dia
<< format::as_hex_dump<4>(value.as_slice()); << format::as_hex_dump<4>(value.as_slice());
if (dialog_id.get_type() != DialogType::SecretChat && m->message_id.is_valid() && m->message_id.is_server()) { if (dialog_id.get_type() != DialogType::SecretChat && m->message_id.is_valid() && m->message_id.is_server()) {
// trying to repair the message // trying to repair the message
get_messages_from_server({FullMessageId{dialog_id, m->message_id}}, Auto()); get_message_from_server({dialog_id, m->message_id}, Auto());
} }
return nullptr; return nullptr;
} }
@ -16485,7 +16489,7 @@ void MessagesManager::on_message_media_edited(DialogId dialog_id, MessageId mess
cancel_upload_message_content_files(m->edited_content.get()); cancel_upload_message_content_files(m->edited_content.get());
if (dialog_id.get_type() != DialogType::SecretChat) { if (dialog_id.get_type() != DialogType::SecretChat) {
get_messages_from_server({FullMessageId{dialog_id, message_id}}, Auto()); get_message_from_server({dialog_id, message_id}, Auto());
} }
} }
@ -18558,7 +18562,7 @@ bool MessagesManager::add_new_message_notification(Dialog *d, Message *m, bool f
send_closure(actor_id, &MessagesManager::flush_pending_new_message_notifications, dialog_id, from_mentions, send_closure(actor_id, &MessagesManager::flush_pending_new_message_notifications, dialog_id, from_mentions,
dialog_id); dialog_id);
}); });
get_messages_from_server({FullMessageId{d->dialog_id, missing_pinned_message_id}}, std::move(promise)); get_message_from_server({d->dialog_id, missing_pinned_message_id}, std::move(promise));
} }
return false; return false;
} }
@ -21190,7 +21194,7 @@ MessagesManager::Message *MessagesManager::on_get_message_from_database(DialogId
} }
// can succeed in private and group chats // can succeed in private and group chats
get_messages_from_server({FullMessageId{dialog_id, m->message_id}}, Auto()); get_message_from_server({dialog_id, m->message_id}, Auto());
force_create_dialog(dialog_id, source); force_create_dialog(dialog_id, source);
d = get_dialog_force(dialog_id); d = get_dialog_force(dialog_id);
@ -21813,7 +21817,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
need_reget_message_content(m->content.get())) { need_reget_message_content(m->content.get())) {
FullMessageId full_message_id{dialog_id, message_id}; FullMessageId full_message_id{dialog_id, message_id};
LOG(INFO) << "Reget from server " << full_message_id; LOG(INFO) << "Reget from server " << full_message_id;
get_messages_from_server({full_message_id}, Auto()); get_message_from_server(full_message_id, Auto());
} }
add_message_file_sources(dialog_id, m); add_message_file_sources(dialog_id, m);
@ -23986,7 +23990,7 @@ void MessagesManager::after_get_channel_difference(DialogId dialog_id, bool succ
// message will not be added to the dialog anyway, get channel difference didn't help // message will not be added to the dialog anyway, get channel difference didn't help
request.second.set_value(Unit()); request.second.set_value(Unit());
} else { } else {
get_messages_from_server({FullMessageId{dialog_id, message_id}}, std::move(request.second)); get_message_from_server({dialog_id, message_id}, std::move(request.second));
} }
} }
postponed_get_message_requests_.erase(it_get_message_requests); postponed_get_message_requests_.erase(it_get_message_requests);

View File

@ -471,6 +471,9 @@ class MessagesManager : public Actor {
bool get_messages(DialogId dialog_id, const vector<MessageId> &message_ids, Promise<Unit> &&promise); bool get_messages(DialogId dialog_id, const vector<MessageId> &message_ids, Promise<Unit> &&promise);
void get_message_from_server(FullMessageId full_message_id, Promise<Unit> &&promise,
tl_object_ptr<telegram_api::InputMessage> input_message = nullptr);
void get_messages_from_server(vector<FullMessageId> &&message_ids, Promise<Unit> &&promise, void get_messages_from_server(vector<FullMessageId> &&message_ids, Promise<Unit> &&promise,
tl_object_ptr<telegram_api::InputMessage> input_message = nullptr); tl_object_ptr<telegram_api::InputMessage> input_message = nullptr);