diff options
| author | levlam <levlam@telegram.org> | 2026-01-19 17:19:04 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2026-01-19 17:19:04 +0300 |
| commit | 832cabe1455d87401b436f7e1a4bb018c728787b (patch) | |
| tree | 2f0b483ba5474fde0f4ad10eee369f91c4e5b190 | |
| parent | 3c69fca9ed65bf9dcbbe898ba2d383a1222ae9ce (diff) | |
Add td_api::internalLinkTypeSearch.
| -rw-r--r-- | td/generate/scheme/td_api.tl | 3 | ||||
| -rw-r--r-- | td/telegram/LinkManager.cpp | 14 | ||||
| -rw-r--r-- | td/telegram/LinkManager.h | 1 | ||||
| -rw-r--r-- | test/link.cpp | 16 |
4 files changed, 29 insertions, 5 deletions
diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index a2151b4c2..edfd159dc 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -8679,6 +8679,9 @@ internalLinkTypeRestorePurchases = InternalLinkType; //@description The link is a link to the Saved Messages chat. Call createPrivateChat with getOption("my_id") and open the chat internalLinkTypeSavedMessages = InternalLinkType; +//@description The link is a link to the global chat and messages search field +internalLinkTypeSearch = InternalLinkType; + //@description The link is a link to application settings @section Section of the application settings to open; may be null if none internalLinkTypeSettings section:SettingsSection = InternalLinkType; diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp index bc647beaf..52077492b 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -1103,6 +1103,12 @@ class LinkManager::InternalLinkSavedMessages final : public InternalLink { } }; +class LinkManager::InternalLinkSearch final : public InternalLink { + td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final { + return td_api::make_object<td_api::internalLinkTypeSearch>(); + } +}; + class LinkManager::InternalLinkSettings final : public InternalLink { vector<string> path_; @@ -2129,6 +2135,9 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_tg_link_query(Slice que return td::make_unique<InternalLinkContacts>(path[1]); } return td::make_unique<InternalLinkContacts>(string()); + } else if (path.size() >= 2 && path[0] == "chat" && path[1] == "search") { + // chat/search + return td::make_unique<InternalLinkSearch>(); } else if (path.size() == 1 && path[0] == "login") { // login?code=123456 auto code = get_arg("code"); @@ -3371,6 +3380,11 @@ Result<string> LinkManager::get_internal_link_impl(const td_api::InternalLinkTyp return Status::Error("HTTP link is unavailable for the link type"); } return "tg://settings/saved-messages"; + case td_api::internalLinkTypeSearch::ID: + if (!is_internal) { + return Status::Error("HTTP link is unavailable for the link type"); + } + return "tg://chat/search"; case td_api::internalLinkTypeSettings::ID: { auto link = static_cast<const td_api::internalLinkTypeSettings *>(type_ptr); if (!is_internal) { diff --git a/td/telegram/LinkManager.h b/td/telegram/LinkManager.h index dc25b1fe5..0d0c32101 100644 --- a/td/telegram/LinkManager.h +++ b/td/telegram/LinkManager.h @@ -167,6 +167,7 @@ class LinkManager final : public Actor { class InternalLinkQrCodeAuthentication; class InternalLinkRestorePurchases; class InternalLinkSavedMessages; + class InternalLinkSearch; class InternalLinkSettings; class InternalLinkStickerSet; class InternalLinkStarGiftCollection; diff --git a/test/link.cpp b/test/link.cpp index 1d7369b59..7e2e8048a 100644 --- a/test/link.cpp +++ b/test/link.cpp @@ -255,14 +255,14 @@ static auto qr_code(td::string subsection = td::string()) { return settings(td::td_api::make_object<td::td_api::settingsSectionQrCode>(subsection)); } -static auto search() { - return settings(td::td_api::make_object<td::td_api::settingsSectionSearch>()); -} - static auto send_gift(td::string subsection = td::string()) { return settings(td::td_api::make_object<td::td_api::settingsSectionSendGift>(subsection)); } +static auto settings_search() { + return settings(td::td_api::make_object<td::td_api::settingsSectionSearch>()); +} + static auto target_chat_chosen(bool allow_users, bool allow_bots, bool allow_groups, bool allow_channels) { return td::td_api::make_object<td::td_api::targetChatChosen>( td::td_api::make_object<td::td_api::targetChatTypes>(allow_users, allow_bots, allow_groups, allow_channels)); @@ -471,6 +471,10 @@ static auto saved_messages() { return td::td_api::make_object<td::td_api::internalLinkTypeSavedMessages>(); } +static auto search() { + return td::td_api::make_object<td::td_api::internalLinkTypeSearch>(); +} + static auto sticker_set(const td::string &sticker_set_name, bool expect_custom_emoji) { return td::td_api::make_object<td::td_api::internalLinkTypeStickerSet>(sticker_set_name, expect_custom_emoji); } @@ -992,6 +996,8 @@ TEST(Link, parse_internal_link_part2) { parse_internal_link("tg://settings/my-profile/posts/add-album", my_profile("posts/add-album")); parse_internal_link("tg://settings/my-profile/archived-posts", my_profile("archived-posts")); + parse_internal_link("tg://chat/search/", search()); + parse_internal_link("tg://contacts", contacts("")); parse_internal_link("tg://contacts/asdasd", contacts("")); parse_internal_link("tg://contacts/new", contacts("new")); @@ -1926,7 +1932,7 @@ TEST(Link, parse_internal_link_part4) { parse_internal_link("tg://settings/privacy-policy", privacy_policy()); parse_internal_link("tg://search", unknown_deep_link("tg://search")); - parse_internal_link("tg://settings/search", search()); + parse_internal_link("tg://settings/search", settings_search()); parse_internal_link("tg://settings/chat/browser", in_app_browser()); parse_internal_link("tg://settings/chat/browser/", in_app_browser()); |
