From 5b941456d2e7e1a94e13c91f83b59ee4cd4c14ae Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 9 Jan 2019 05:57:43 +0300 Subject: [PATCH] Add td_api::getMessageLocally. GitOrigin-RevId: 8b6dec4aadc0d9b1005444fe82a7db12cf1841a7 --- td/generate/scheme/td_api.tl | 5 ++++- td/generate/scheme/td_api.tlo | Bin 139940 -> 140068 bytes td/telegram/MessagesManager.cpp | 4 +--- td/telegram/Td.cpp | 5 +++++ td/telegram/Td.h | 2 ++ td/telegram/cli.cpp | 5 +++++ 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index dbd79642..e147edf6 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -109,7 +109,7 @@ authorizationStateClosing = AuthorizationState; authorizationStateClosed = AuthorizationState; -//@description Represents the current state of 2-step verification @has_password True if a 2-step verification password is set @password_hint Hint for the password; can be empty @has_recovery_email_address True if a recovery email is set @has_passport_data True if some Telegram Passport elements were saved @unconfirmed_recovery_email_address_pattern Pattern of the email address to which the confirmation email was sent +//@description Represents the current state of 2-step verification @has_password True, if a 2-step verification password is set @password_hint Hint for the password; can be empty @has_recovery_email_address True, if a recovery email is set @has_passport_data True, if some Telegram Passport elements were saved @unconfirmed_recovery_email_address_pattern Pattern of the email address to which the confirmation email was sent passwordState has_password:Bool password_hint:string has_recovery_email_address:Bool has_passport_data:Bool unconfirmed_recovery_email_address_pattern:string = PasswordState; //@description Contains information about the current recovery email address @recovery_email_address Recovery email address @@ -2547,6 +2547,9 @@ getChat chat_id:int53 = Chat; //@description Returns information about a message @chat_id Identifier of the chat the message belongs to @message_id Identifier of the message to get getMessage chat_id:int53 message_id:int53 = Message; +//@description Returns information about a message, if it is available locally without sending network request. This is an offline request @chat_id Identifier of the chat the message belongs to @message_id Identifier of the message to get +getMessageLocally chat_id:int53 message_id:int53 = Message; + //@description Returns information about a message that is replied by given message @chat_id Identifier of the chat the message belongs to @message_id Identifier of the message reply to which get getRepliedMessage chat_id:int53 message_id:int53 = Message; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 84941a1e44c634eb5a5eb1dae4423f4559de0611..624a03c0a9bc0a88ba0ed0f5945d4cfbcb65781f 100644 GIT binary patch delta 53 zcmZ2-lw-*;j)pCaKCO(7+kIOZ?>md-XtUiBOiwNGO)V}?Oi%U6PfpCqshqy*B4gHe Jos*0ekpMZp6-WR8 delta 25 hcmZ2-jAO}Bj)pCaKCO%n+kIOZ?>lc_bCR(l5&(`_3e^Ar diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index a8b13f47..c38b28ff 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -14537,9 +14537,7 @@ void MessagesManager::load_messages(DialogId dialog_id, MessageId from_message_i } tl_object_ptr MessagesManager::get_message_object(FullMessageId full_message_id) { - auto dialog_id = full_message_id.get_dialog_id(); - Dialog *d = get_dialog(dialog_id); - return get_message_object(dialog_id, get_message_force(d, full_message_id.get_message_id())); + return get_message_object(full_message_id.get_dialog_id(), get_message_force(full_message_id)); } tl_object_ptr MessagesManager::get_message_object(DialogId dialog_id, const Message *message) const { diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 3528064f..0e952e35 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -4848,6 +4848,11 @@ void Td::on_request(uint64 id, const td_api::getMessage &request) { CREATE_REQUEST(GetMessageRequest, request.chat_id_, request.message_id_); } +void Td::on_request(uint64 id, const td_api::getMessageLocally &request) { + FullMessageId full_message_id(DialogId(request.chat_id_), MessageId(request.message_id_)); + send_closure(actor_id(this), &Td::send_result, id, messages_manager_->get_message_object(full_message_id)); +} + void Td::on_request(uint64 id, const td_api::getRepliedMessage &request) { CREATE_REQUEST(GetRepliedMessageRequest, request.chat_id_, request.message_id_); } diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 2fdab88f..b99e86b8 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -433,6 +433,8 @@ class Td final : public NetQueryCallback { void on_request(uint64 id, const td_api::getMessage &request); + void on_request(uint64 id, const td_api::getMessageLocally &request); + void on_request(uint64 id, const td_api::getRepliedMessage &request); void on_request(uint64 id, const td_api::getChatPinnedMessage &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index ff6adf06..f23c8fe6 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2256,6 +2256,11 @@ class CliClient final : public Actor { string message_id; std::tie(chat_id, message_id) = split(args); send_request(make_tl_object(as_chat_id(chat_id), as_message_id(message_id))); + } else if (op == "gml") { + string chat_id; + string message_id; + std::tie(chat_id, message_id) = split(args); + send_request(make_tl_object(as_chat_id(chat_id), as_message_id(message_id))); } else if (op == "grm") { string chat_id; string message_id;