Add td_api::getInternalLinkType.

This commit is contained in:
levlam 2021-06-01 05:41:32 +03:00
parent 1de8b85809
commit 76f134c0e7
6 changed files with 17 additions and 3 deletions

View File

@ -4349,7 +4349,10 @@ viewMessages chat_id:int53 message_thread_id:int53 message_ids:vector<int53> 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

View File

@ -773,7 +773,7 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_tg_link_query(Slice que
// msg_url?url=<url>&text=<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<InternalLinkUnknownDeepLink>();
}
return nullptr;

View File

@ -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<string> 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<InternalLink> parse_internal_link(Slice link);
void get_login_url_info(DialogId dialog_id, MessageId message_id, int32 button_id,

View File

@ -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_);

View File

@ -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);

View File

@ -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<td_api::openMessageContent>(as_chat_id(chat_id), as_message_id(message_id)));
} else if (op == "gilt") {
string link = args;
send_request(td_api::make_object<td_api::getInternalLinkType>(link));
} else if (op == "geli") {
string link = args;
send_request(td_api::make_object<td_api::getExternalLinkInfo>(link));