diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 70bcd59f5..521be15f9 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -4349,7 +4349,10 @@ viewMessages chat_id:int53 message_thread_id:int53 message_ids:vector for //@description Informs TDLib that the message content has been opened (e.g., the user has opened a photo, video, document, location or venue, or has listened to an audio file or voice note message). An updateMessageContentOpened update will be generated if something has changed @chat_id Chat identifier of the message @message_id Identifier of the message with the opened content openMessageContent chat_id:int53 message_id:int53 = Ok; -//@description Returns information about an action to be done when the current user clicks an HTTP link. This method can be used to automatically authorize the current user on a website. Don't use this method for links from secret chats if link preview is disabled in secret chats @link The HTTP link +//@description Returns information about the type of an internal link. Returns a 404 error if the link is not internal. Can be called before authorization @link The link +getInternalLinkType link:string = InternalLinkType; + +//@description Returns information about an action to be done when the current user clicks an external link. Don't use this method for links from secret chats if link preview is disabled in secret chats @link The link getExternalLinkInfo link:string = LoginUrlInfo; //@description Returns an HTTP URL which can be used to automatically authorize the current user on a website after clicking an HTTP link. Use the method getExternalLinkInfo to find whether a prior user confirmation is needed diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp index e38d8c56c..d2dfc590f 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -773,7 +773,7 @@ unique_ptr LinkManager::parse_tg_link_query(Slice que // msg_url?url=&text= return get_internal_link_message_draft(get_arg("url"), get_arg("text")); } - if (!path.empty()) { + if (!path.empty() && !path[0].empty()) { return td::make_unique(); } return nullptr; diff --git a/td/telegram/LinkManager.h b/td/telegram/LinkManager.h index b5a5dd57f..fb06c9064 100644 --- a/td/telegram/LinkManager.h +++ b/td/telegram/LinkManager.h @@ -49,7 +49,7 @@ class LinkManager : public Actor { // checks whether the link is a valid tg, ton or HTTP(S) URL and returns it in a canonical form static Result check_link(Slice link); - // checks whether the link is a supported tg or t.me URL and parses it + // checks whether the link is a supported tg or t.me link and parses it static unique_ptr parse_internal_link(Slice link); void get_login_url_info(DialogId dialog_id, MessageId message_id, int32 button_id, diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index fc6c14c01..0e7219cf2 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -3286,6 +3286,7 @@ bool Td::is_preinitialization_request(int32 id) { bool Td::is_preauthentication_request(int32 id) { switch (id) { + case td_api::getInternalLinkType::ID: case td_api::getLocalizationTargetInfo::ID: case td_api::getLanguagePackInfo::ID: case td_api::getLanguagePackStrings::ID: @@ -5487,6 +5488,11 @@ void Td::on_request(uint64 id, const td_api::openMessageContent &request) { id, messages_manager_->open_message_content({DialogId(request.chat_id_), MessageId(request.message_id_)})); } +void Td::on_request(uint64 id, const td_api::getInternalLinkType &request) { + auto type = link_manager_->parse_internal_link(request.link_); + send_closure(actor_id(this), &Td::send_result, id, type == nullptr ? nullptr : type->get_internal_link_type_object()); +} + void Td::on_request(uint64 id, td_api::getExternalLinkInfo &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.link_); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 3aaa4e380..75a6a8b33 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -580,6 +580,8 @@ class Td final : public NetQueryCallback { void on_request(uint64 id, const td_api::openMessageContent &request); + void on_request(uint64 id, const td_api::getInternalLinkType &request); + void on_request(uint64 id, td_api::getExternalLinkInfo &request); void on_request(uint64 id, td_api::getExternalLink &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 7f3d24c4d..91ca6d153 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -4002,6 +4002,9 @@ class CliClient final : public Actor { string message_id; get_args(args, chat_id, message_id); send_request(td_api::make_object(as_chat_id(chat_id), as_message_id(message_id))); + } else if (op == "gilt") { + string link = args; + send_request(td_api::make_object(link)); } else if (op == "geli") { string link = args; send_request(td_api::make_object(link));