diff options
| author | levlam <levlam@telegram.org> | 2025-08-01 14:58:38 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2025-08-01 14:58:38 +0300 |
| commit | eab09d20ea00dd682c7d2444352c49c14ddb6c78 (patch) | |
| tree | d27e6bd7bff229b3c8ad6b4a49265511a9918080 | |
| parent | 2cc3e239f60c1c8d23bb21f8a1845bd6ab639f11 (diff) | |
Add td_api::internalLinkTypeMyToncoins.
| -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 | 12 |
4 files changed, 30 insertions, 0 deletions
diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 2b7172854..48fef74f7 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -7808,6 +7808,9 @@ internalLinkTypeMessageDraft text:formattedText contains_link:Bool = InternalLin //@description The link is a link to the screen with information about Telegram Star balance and transactions of the current user internalLinkTypeMyStars = InternalLinkType; +//@description The link is a link to the screen with information about Toncoin balance and transactions of the current user +internalLinkTypeMyToncoins = InternalLinkType; + //@description The link contains a request of Telegram passport data. Call getPassportAuthorizationForm with the given parameters to process the link if the link was received from outside of the application; otherwise, ignore it //@bot_user_id User identifier of the service's bot; the corresponding user may be unknown yet //@scope Telegram Passport element types requested by the service diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp index 16007e367..c46aac16b 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -723,6 +723,12 @@ class LinkManager::InternalLinkMyStars final : public InternalLink { } }; +class LinkManager::InternalLinkMyToncoins final : public InternalLink { + td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final { + return td_api::make_object<td_api::internalLinkTypeMyToncoins>(); + } +}; + class LinkManager::InternalLinkPassportDataRequest final : public InternalLink { UserId bot_user_id_; string scope_; @@ -1729,6 +1735,9 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_tg_link_query(Slice que } else if (!path.empty() && path[0] == "stars") { // stars return td::make_unique<InternalLinkMyStars>(); + } else if (!path.empty() && path[0] == "ton") { + // ton + return td::make_unique<InternalLinkMyToncoins>(); } else if (path.size() == 1 && path[0] == "addlist") { auto slug = get_url_query_slug(true, url_query, "addlist"); if (!slug.empty() && is_base64url_characters(slug)) { @@ -2695,6 +2704,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://stars"; + case td_api::internalLinkTypeMyToncoins::ID: + if (!is_internal) { + return Status::Error("HTTP link is unavailable for the link type"); + } + return "tg://ton"; case td_api::internalLinkTypePassportDataRequest::ID: { auto link = static_cast<const td_api::internalLinkTypePassportDataRequest *>(type_ptr); if (!is_internal) { diff --git a/td/telegram/LinkManager.h b/td/telegram/LinkManager.h index b671eb857..655ed05fd 100644 --- a/td/telegram/LinkManager.h +++ b/td/telegram/LinkManager.h @@ -155,6 +155,7 @@ class LinkManager final : public Actor { class InternalLinkMessage; class InternalLinkMessageDraft; class InternalLinkMyStars; + class InternalLinkMyToncoins; class InternalLinkPassportDataRequest; class InternalLinkPremiumFeatures; class InternalLinkPremiumGift; diff --git a/test/link.cpp b/test/link.cpp index 6e316ab79..eb88eed06 100644 --- a/test/link.cpp +++ b/test/link.cpp @@ -317,6 +317,10 @@ static auto my_stars() { return td::td_api::make_object<td::td_api::internalLinkTypeMyStars>(); } +static auto my_toncoins() { + return td::td_api::make_object<td::td_api::internalLinkTypeMyToncoins>(); +} + static auto passport_data_request(td::int32 bot_user_id, const td::string &scope, const td::string &public_key, const td::string &nonce, const td::string &callback_url) { return td::td_api::make_object<td::td_api::internalLinkTypePassportDataRequest>(bot_user_id, scope, public_key, nonce, @@ -1563,6 +1567,14 @@ TEST(Link, parse_internal_link_part4) { parse_internal_link("tg://stars/theme#test", my_stars()); parse_internal_link("tg:stars/theme#test", my_stars()); + parse_internal_link("tg://ton", my_toncoins()); + parse_internal_link("tg://ton?asdsa?D?SADasD?asD", my_toncoins()); + parse_internal_link("tg://ton#test", my_toncoins()); + parse_internal_link("tg://ton/#test", my_toncoins()); + parse_internal_link("tg://ton/aadsa#test", my_toncoins()); + parse_internal_link("tg://ton/theme#test", my_toncoins()); + parse_internal_link("tg:ton/theme#test", my_toncoins()); + parse_internal_link("tg://stars_topup", unknown_deep_link("tg://stars_topup")); parse_internal_link("tg://stars_topup?balance=", unknown_deep_link("tg://stars_topup?balance=")); parse_internal_link("tg://stars_topup?balance=test", buy_stars(1, "")); |
