Add internalLinkTypeRestorePurchases.

This commit is contained in:
levlam 2022-07-25 12:06:32 +03:00
parent 4e9c7ffbf2
commit d4b59bda87
4 changed files with 24 additions and 0 deletions

View File

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

View File

@ -487,6 +487,12 @@ class LinkManager::InternalLinkQrCodeAuthentication final : public InternalLink
}
};
class LinkManager::InternalLinkRestorePurchases final : public InternalLink {
td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final {
return td_api::make_object<td_api::internalLinkTypeRestorePurchases>();
}
};
class LinkManager::InternalLinkSettings final : public InternalLink {
td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final {
return td_api::make_object<td_api::internalLinkTypeSettings>();
@ -1068,6 +1074,9 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_tg_link_query(Slice que
if (has_arg("token")) {
return td::make_unique<InternalLinkQrCodeAuthentication>();
}
} else if (path.size() == 1 && path[0] == "restore_purchases") {
// restore_purchases
return td::make_unique<InternalLinkRestorePurchases>();
} else if (path.size() == 1 && path[0] == "passport") {
// passport?bot_id=<bot_user_id>&scope=<scope>&public_key=<public_key>&nonce=<nonce>
return get_internal_link_passport(query, url_query.args_);

View File

@ -112,6 +112,7 @@ class LinkManager final : public Actor {
class InternalLinkProxy;
class InternalLinkPublicDialog;
class InternalLinkQrCodeAuthentication;
class InternalLinkRestorePurchases;
class InternalLinkSettings;
class InternalLinkStickerSet;
class InternalLinkTheme;

View File

@ -201,6 +201,9 @@ TEST(Link, parse_internal_link) {
auto qr_code_authentication = [] {
return td::td_api::make_object<td::td_api::internalLinkTypeQrCodeAuthentication>();
};
auto restore_purchases = [] {
return td::td_api::make_object<td::td_api::internalLinkTypeRestorePurchases>();
};
auto settings = [] {
return td::td_api::make_object<td::td_api::internalLinkTypeSettings>();
};
@ -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);