From d4b59bda87d40f83e94f4cf48ccc63d69b5259cd Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 25 Jul 2022 12:06:32 +0300 Subject: [PATCH] Add internalLinkTypeRestorePurchases. --- td/generate/scheme/td_api.tl | 3 +++ td/telegram/LinkManager.cpp | 9 +++++++++ td/telegram/LinkManager.h | 1 + test/link.cpp | 11 +++++++++++ 4 files changed, 24 insertions(+) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0a9710558..eb60be26f 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3720,6 +3720,9 @@ 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 forces restore of App Store purchases when opened. For official iOS application only +internalLinkTypeRestorePurchases = InternalLinkType; + //@description The link is a link to application settings internalLinkTypeSettings = InternalLinkType; diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp index 6a4992d00..ad4175070 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -487,6 +487,12 @@ class LinkManager::InternalLinkQrCodeAuthentication final : public InternalLink } }; +class LinkManager::InternalLinkRestorePurchases final : public InternalLink { + td_api::object_ptr get_internal_link_type_object() const final { + return td_api::make_object(); + } +}; + class LinkManager::InternalLinkSettings final : public InternalLink { td_api::object_ptr get_internal_link_type_object() const final { return td_api::make_object(); @@ -1068,6 +1074,9 @@ unique_ptr LinkManager::parse_tg_link_query(Slice que if (has_arg("token")) { return td::make_unique(); } + } else if (path.size() == 1 && path[0] == "restore_purchases") { + // restore_purchases + return td::make_unique(); } else if (path.size() == 1 && path[0] == "passport") { // passport?bot_id=&scope=&public_key=&nonce= return get_internal_link_passport(query, url_query.args_); diff --git a/td/telegram/LinkManager.h b/td/telegram/LinkManager.h index d2e9f3850..579fcba97 100644 --- a/td/telegram/LinkManager.h +++ b/td/telegram/LinkManager.h @@ -112,6 +112,7 @@ class LinkManager final : public Actor { class InternalLinkProxy; class InternalLinkPublicDialog; class InternalLinkQrCodeAuthentication; + class InternalLinkRestorePurchases; class InternalLinkSettings; class InternalLinkStickerSet; class InternalLinkTheme; diff --git a/test/link.cpp b/test/link.cpp index ace300ff5..bc2be9434 100644 --- a/test/link.cpp +++ b/test/link.cpp @@ -201,6 +201,9 @@ TEST(Link, parse_internal_link) { auto qr_code_authentication = [] { return td::td_api::make_object(); }; + auto restore_purchases = [] { + return td::td_api::make_object(); + }; auto settings = [] { return td::td_api::make_object(); }; @@ -510,6 +513,14 @@ TEST(Link, parse_internal_link) { parse_internal_link("tg:login?token=abacaba", qr_code_authentication()); parse_internal_link("tg:login?token=", unknown_deep_link("tg://login?token=")); + parse_internal_link("tg:restore_purchases?token=abacaba", restore_purchases()); + parse_internal_link("tg:restore_purchases?#", restore_purchases()); + parse_internal_link("tg:restore_purchases/?#", restore_purchases()); + parse_internal_link("tg:restore_purchases", restore_purchases()); + parse_internal_link("tg:restore_purchase", unknown_deep_link("tg://restore_purchase")); + parse_internal_link("tg:restore_purchasess", unknown_deep_link("tg://restore_purchasess")); + parse_internal_link("tg:restore_purchases/test?#", unknown_deep_link("tg://restore_purchases/test?")); + parse_internal_link("t.me/joinchat?invite=abcdef", nullptr); parse_internal_link("t.me/joinchat", nullptr); parse_internal_link("t.me/joinchat/", nullptr);