From 6e139200eb634b936bfb25132f4a9ec559ae0dbe Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 30 Mar 2023 21:25:25 +0300 Subject: [PATCH] Use get_dialog_invite_link/get_dialog_filter_invite_link to generate the links. --- td/telegram/LinkManager.cpp | 20 ++++++++++---------- td/telegram/LinkManager.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp index eb73cffa1..04a4124c6 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -1292,14 +1292,14 @@ unique_ptr LinkManager::parse_tg_link_query(Slice que } else if (path.size() == 1 && path[0] == "list") { auto slug = get_url_query_slug(true, url_query); if (!slug.empty() && is_base64url_characters(slug)) { - // list?slug= - return td::make_unique(PSTRING() << "tg:list?slug=" << slug); + // list?slug= + return td::make_unique(get_dialog_filter_invite_link(slug, true)); } } else if (path.size() == 1 && path[0] == "join") { auto invite_hash = get_url_query_hash(true, url_query); if (!invite_hash.empty() && !is_valid_phone_number(invite_hash) && is_base64url_characters(invite_hash)) { // join?invite= - return td::make_unique(PSTRING() << "tg:join?invite=" << invite_hash); + return td::make_unique(get_dialog_invite_link(invite_hash, true)); } } else if (path.size() == 1 && (path[0] == "addstickers" || path[0] == "addemoji")) { // addstickers?set= @@ -1429,13 +1429,13 @@ unique_ptr LinkManager::parse_t_me_link_query(Slice q auto slug = get_url_query_slug(false, url_query); if (!slug.empty() && is_base64url_characters(slug)) { // /list/ - return td::make_unique(PSTRING() << "tg:list?slug=" << slug); + return td::make_unique(get_dialog_filter_invite_link(slug, true)); } } else if (path[0] == "joinchat") { auto invite_hash = get_url_query_hash(false, url_query); if (!invite_hash.empty() && !is_valid_phone_number(invite_hash) && is_base64url_characters(invite_hash)) { // /joinchat/ - return td::make_unique(PSTRING() << "tg:join?invite=" << invite_hash); + return td::make_unique(get_dialog_invite_link(invite_hash, true)); } } else if (path[0][0] == ' ' || path[0][0] == '+') { auto invite_hash = get_url_query_hash(false, url_query); @@ -1451,7 +1451,7 @@ unique_ptr LinkManager::parse_t_me_link_query(Slice q return std::move(user_link); } else if (!invite_hash.empty() && is_base64url_characters(invite_hash)) { // /+ - return td::make_unique(PSTRING() << "tg:join?invite=" << invite_hash); + return td::make_unique(get_dialog_invite_link(invite_hash, true)); } } else if (path[0] == "contact") { if (path.size() >= 2 && !path[1].empty()) { @@ -2350,14 +2350,14 @@ string LinkManager::get_dialog_invite_link_hash(Slice invite_link) { return invite_hash; } -string LinkManager::get_dialog_invite_link(Slice hash, bool is_internal) { - if (!is_base64url_characters(hash)) { +string LinkManager::get_dialog_invite_link(Slice invite_hash, bool is_internal) { + if (!is_base64url_characters(invite_hash)) { return string(); } if (is_internal) { - return PSTRING() << "tg:join?invite=" << hash; + return PSTRING() << "tg:join?invite=" << invite_hash; } else { - return PSTRING() << get_t_me_url() << '+' << hash; + return PSTRING() << get_t_me_url() << '+' << invite_hash; } } diff --git a/td/telegram/LinkManager.h b/td/telegram/LinkManager.h index 6d4a5f367..4796b24d2 100644 --- a/td/telegram/LinkManager.h +++ b/td/telegram/LinkManager.h @@ -89,7 +89,7 @@ class LinkManager final : public Actor { static string get_dialog_invite_link_hash(Slice invite_link); - static string get_dialog_invite_link(Slice hash, bool is_internal); + static string get_dialog_invite_link(Slice invite_hash, bool is_internal); static string get_instant_view_link_url(Slice link);