diff options
| author | levlam <levlam@telegram.org> | 2026-01-13 17:11:55 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2026-01-13 17:11:55 +0300 |
| commit | 4565767812d83b993e54a6a97be64e788aab0eba (patch) | |
| tree | c54921b98ca0bb1e29c9124474a78fe001a91957 | |
| parent | ebf736e46e98cbcb88cca4f8b836203b90e1ec89 (diff) | |
Add td_api::internalLinkTypeNewPrivateChat.
| -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 | 8 |
4 files changed, 26 insertions, 0 deletions
diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index ba02ad3e7..6ecb52842 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -8568,6 +8568,9 @@ internalLinkTypeMessageDraft text:formattedText contains_link:Bool = InternalLin //-"posts", "posts/all-stories", "posts/add-album", "gifts", "archived-posts" internalLinkTypeMyProfile section:string = InternalLinkType; +//@description The link is a link to the screen for creating a new private chat with a contact +internalLinkTypeNewPrivateChat = 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 48a70a3a0..c1c206afe 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -917,6 +917,12 @@ class LinkManager::InternalLinkMyProfile final : public InternalLink { } }; +class LinkManager::InternalLinkNewPrivateChat final : public InternalLink { + td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final { + return td_api::make_object<td_api::internalLinkTypeNewPrivateChat>(); + } +}; + class LinkManager::InternalLinkPassportDataRequest final : public InternalLink { UserId bot_user_id_; string scope_; @@ -2071,6 +2077,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] == "new") { + // new + return td::make_unique<InternalLinkNewPrivateChat>(); } else if (path.size() == 1 && path[0] == "restore_purchases") { // restore_purchases return td::make_unique<InternalLinkRestorePurchases>(); @@ -3155,6 +3164,11 @@ Result<string> LinkManager::get_internal_link_impl(const td_api::InternalLinkTyp } return "tg://settings/my-profile"; } + case td_api::internalLinkTypeNewPrivateChat::ID: + if (!is_internal) { + return Status::Error("HTTP link is unavailable for the link type"); + } + return "tg://new"; 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 4ec91dd0a..5aa9edac6 100644 --- a/td/telegram/LinkManager.h +++ b/td/telegram/LinkManager.h @@ -153,6 +153,7 @@ class LinkManager final : public Actor { class InternalLinkMessageDraft; class InternalLinkMonoforum; class InternalLinkMyProfile; + class InternalLinkNewPrivateChat; class InternalLinkPassportDataRequest; class InternalLinkPremiumFeatures; class InternalLinkPremiumGift; diff --git a/test/link.cpp b/test/link.cpp index 02cdf98d5..1e5ccc154 100644 --- a/test/link.cpp +++ b/test/link.cpp @@ -401,6 +401,10 @@ static auto my_profile(const td::string §ion) { return td::td_api::make_object<td::td_api::internalLinkTypeMyProfile>(section); } +static auto new_private_chat() { + return td::td_api::make_object<td::td_api::internalLinkTypeNewPrivateChat>(); +} + 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, @@ -972,6 +976,10 @@ 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://new", new_private_chat()); + parse_internal_link("tg://new/", new_private_chat()); + parse_internal_link("tg://new/asd", unknown_deep_link("tg://new/asd")); + parse_internal_link("t.me/joinchat?invite=abcdef", nullptr); parse_internal_link("t.me/joinchat", nullptr); parse_internal_link("t.me/joinchat/", nullptr); |
