diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 7864e5268..70bcd59f5 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3000,6 +3000,9 @@ chatReportReasonCustom = ChatReportReason; //@class InternalLinkType @description Describes an internal https://t.me or tg: link, which must be processed by the app in a special way +//@description The link is a link to the active sessions section of the app. Use getActiveSessions to handle the link +internalLinkTypeActiveSessions = InternalLinkType; + //@description The link contains an authentication code. Call checkAuthenticationCode with the code if the current authorization state is authorizationStateWaitCode @code The authentication code internalLinkTypeAuthenticationCode code:string = InternalLinkType; @@ -3016,9 +3019,15 @@ internalLinkTypeBotStart bot_username:string start_parameter:string = InternalLi //@bot_username Username of the bot @start_parameter The parameter to be passed to sendBotStartMessage internalLinkTypeBotStartInGroup bot_username:string start_parameter:string = InternalLinkType; +//@description The link is a link to the change phone number section of the app +internalLinkTypeChangePhoneNumber = InternalLinkType; + //@description The link is a chat invite link. Call checkChatInviteLink to process the link internalLinkTypeChatInvite = InternalLinkType; +//@description The link is a link to the filter settings section of the app +internalLinkTypeFilterSettings = InternalLinkType; + //@description The link is a link to a game. Call searchPublicChat with the given bot username, check that the user is a bot, ask the current user to select a group to send the game, and then call sendMessage with inputMessageGame //@bot_username Username of the bot that owns the game @game_short_name Short name of the game internalLinkTypeGame bot_username:string game_short_name:string = InternalLinkType; @@ -3053,12 +3062,18 @@ internalLinkTypePublicChat chat_username:string = InternalLinkType; //-"This code can be used to allow someone to log in to your Telegram account. To confirm Telegram login, please go to Settings > Devices > Scan QR and scan the code" needs to be shown internalLinkTypeQrCodeAuthentication = InternalLinkType; +//@description The link is a link to app settings +internalLinkTypeSettings = InternalLinkType; + //@description The link is a link to a sticker set. Call searchStickerSet with the given sticker set name to process the link and show the sticker set @sticker_set_name Name of the sticker set internalLinkTypeStickerSet sticker_set_name:string = InternalLinkType; //@description The link is a link to a theme. TDLib has no theme support yet @theme_name Name of the theme internalLinkTypeTheme theme_name:string = InternalLinkType; +//@description The link is a link to the theme settings section of the app +internalLinkTypeThemeSettings = InternalLinkType; + //@description The link is an unknown tg: link. Call getDeepLinkInfo to process the link internalLinkTypeUnknownDeepLink = InternalLinkType; diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp index 264649424..e38d8c56c 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -56,6 +56,12 @@ static bool is_valid_username(Slice username) { return true; } +class LinkManager::InternalLinkActiveSessions : public InternalLink { + td_api::object_ptr get_internal_link_type_object() const final { + return td_api::make_object(); + } +}; + class LinkManager::InternalLinkAuthenticationCode : public InternalLink { string code_; @@ -108,6 +114,12 @@ class LinkManager::InternalLinkBotStartInGroup : public InternalLink { } }; +class LinkManager::InternalLinkChangePhoneNumber : public InternalLink { + td_api::object_ptr get_internal_link_type_object() const final { + return td_api::make_object(); + } +}; + class LinkManager::InternalLinkConfirmPhone : public InternalLink { string hash_; string phone_number_; @@ -128,6 +140,12 @@ class LinkManager::InternalLinkDialogInvite : public InternalLink { } }; +class LinkManager::InternalLinkFilterSettings : public InternalLink { + td_api::object_ptr get_internal_link_type_object() const final { + return td_api::make_object(); + } +}; + class LinkManager::InternalLinkGame : public InternalLink { string bot_username_; string game_short_name_; @@ -246,6 +264,12 @@ class LinkManager::InternalLinkQrCodeAuthentication : public InternalLink { } }; +class LinkManager::InternalLinkSettings : public InternalLink { + td_api::object_ptr get_internal_link_type_object() const final { + return td_api::make_object(); + } +}; + class LinkManager::InternalLinkStickerSet : public InternalLink { string sticker_set_name_; @@ -270,6 +294,12 @@ class LinkManager::InternalLinkTheme : public InternalLink { } }; +class LinkManager::InternalLinkThemeSettings : public InternalLink { + td_api::object_ptr get_internal_link_type_object() const final { + return td_api::make_object(); + } +}; + class LinkManager::InternalLinkUnknownDeepLink : public InternalLink { td_api::object_ptr get_internal_link_type_object() const final { return td_api::make_object(); @@ -654,6 +684,25 @@ unique_ptr LinkManager::parse_tg_link_query(Slice que } else if (path.size() == 1 && path[0] == "passport") { // passport?bot_id=&scope=&public_key=&nonce= return get_internal_link_passport(url_query.args_); + } else if (path.size() >= 1 && path[0] == "settings") { + if (path.size() == 2 && path[1] == "change_number") { + // settings/change_number + return td::make_unique(); + } + if (path.size() == 2 && path[1] == "devices") { + // settings/devices + return td::make_unique(); + } + if (path.size() == 2 && path[1] == "folders") { + // settings/folders + return td::make_unique(); + } + if (path.size() == 2 && path[1] == "themes") { + // settings/themes + return td::make_unique(); + } + // settings + return td::make_unique(); } else if (path.size() == 1 && path[0] == "join") { // join?invite= if (has_arg("invite")) { diff --git a/td/telegram/LinkManager.h b/td/telegram/LinkManager.h index d40341354..b5a5dd57f 100644 --- a/td/telegram/LinkManager.h +++ b/td/telegram/LinkManager.h @@ -70,12 +70,15 @@ class LinkManager : public Actor { private: void tear_down() override; + class InternalLinkActiveSessions; class InternalLinkAuthenticationCode; class InternalLinkBackground; class InternalLinkBotStart; class InternalLinkBotStartInGroup; + class InternalLinkChangePhoneNumber; class InternalLinkConfirmPhone; class InternalLinkDialogInvite; + class InternalLinkFilterSettings; class InternalLinkGame; class InternalLinkLanguage; class InternalLinkMessage; @@ -84,8 +87,10 @@ class LinkManager : public Actor { class InternalLinkProxy; class InternalLinkPublicDialog; class InternalLinkQrCodeAuthentication; + class InternalLinkSettings; class InternalLinkStickerSet; class InternalLinkTheme; + class InternalLinkThemeSettings; class InternalLinkUnknownDeepLink; class InternalLinkVoiceChat; diff --git a/test/link.cpp b/test/link.cpp index 86bffb8cf..5c357d28e 100644 --- a/test/link.cpp +++ b/test/link.cpp @@ -63,6 +63,9 @@ static void parse_internal_link(td::string url, td::td_api::object_ptr(); + }; auto authentication_code = [](td::string code) { return td::td_api::make_object(code); }; @@ -75,9 +78,15 @@ TEST(Link, parse_internal_link) { auto bot_start_in_group = [](td::string bot_username, td::string start_parameter) { return td::td_api::make_object(bot_username, start_parameter); }; + auto change_phone_number = [] { + return td::td_api::make_object(); + }; auto chat_invite = [] { return td::td_api::make_object(); }; + auto filter_settings = [] { + return td::td_api::make_object(); + }; auto game = [](td::string bot_username, td::string game_short_name) { return td::td_api::make_object(bot_username, game_short_name); }; @@ -111,15 +120,21 @@ TEST(Link, parse_internal_link) { auto public_chat = [](td::string chat_username) { return td::td_api::make_object(chat_username); }; - auto qr_code_authentication = []() { + auto qr_code_authentication = [] { return td::td_api::make_object(); }; + auto settings = [] { + return td::td_api::make_object(); + }; auto sticker_set = [](td::string sticker_set_name) { return td::td_api::make_object(sticker_set_name); }; auto theme = [](td::string theme_name) { return td::td_api::make_object(theme_name); }; + auto theme_settings = [] { + return td::td_api::make_object(); + }; auto unknown_deep_link = [] { return td::td_api::make_object(); }; @@ -566,4 +581,21 @@ TEST(Link, parse_internal_link) { parse_internal_link("tg://passport?bot_id=12345&public_key=key&scope=asd&payload=", unknown_deep_link()); parse_internal_link("t.me/telegrampassport?bot_id=12345&public_key=key&scope=asd&payload=nonce", public_chat("telegrampassport")); + + parse_internal_link("tg://settings", settings()); + parse_internal_link("tg://setting", unknown_deep_link()); + parse_internal_link("tg://settings?asdsa?D?SADasD?asD", settings()); + parse_internal_link("tg://settings#test", settings()); + parse_internal_link("tg://settings/#test", settings()); + parse_internal_link("tg://settings/aadsa#test", settings()); + parse_internal_link("tg://settings/theme#test", settings()); + parse_internal_link("tg://settings/themes#test", theme_settings()); + parse_internal_link("tg://settings/themesa#test", settings()); + parse_internal_link("tg://settings/themes/?as#rad", theme_settings()); + parse_internal_link("tg://settings/themes/a", settings()); + parse_internal_link("tg://settings/asdsathemesasdas/devices", settings()); + parse_internal_link("tg://settings/devices", active_sessions()); + parse_internal_link("tg://settings/change_number", change_phone_number()); + parse_internal_link("tg://settings/folders", filter_settings()); + parse_internal_link("tg://settings/filters", settings()); }