Update folder invite links format.
This commit is contained in:
parent
f431c8ba5a
commit
cc062c6b11
@ -90,13 +90,13 @@ static string get_url_query_hash(bool is_tg, const HttpUrlQuery &url_query) {
|
|||||||
static string get_url_query_slug(bool is_tg, const HttpUrlQuery &url_query) {
|
static string get_url_query_slug(bool is_tg, const HttpUrlQuery &url_query) {
|
||||||
const auto &path = url_query.path_;
|
const auto &path = url_query.path_;
|
||||||
if (is_tg) {
|
if (is_tg) {
|
||||||
if (path.size() == 1 && path[0] == "list") {
|
if (path.size() == 1 && path[0] == "addlist") {
|
||||||
// list?slug=<hash>
|
// addlist?slug=<hash>
|
||||||
return url_query.get_arg("slug").str();
|
return url_query.get_arg("slug").str();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (path.size() >= 2 && path[0] == "list") {
|
if (path.size() >= 2 && path[0] == "addlist") {
|
||||||
// /list/<hash>
|
// /addlist/<hash>
|
||||||
return path[1];
|
return path[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1015,9 +1015,9 @@ LinkManager::LinkInfo LinkManager::get_link_info(Slice link) {
|
|||||||
to_lower_inplace(host);
|
to_lower_inplace(host);
|
||||||
if (ends_with(host, ".t.me") && host.size() >= 9 && host.find('.') == host.size() - 5) {
|
if (ends_with(host, ".t.me") && host.size() >= 9 && host.find('.') == host.size() - 5) {
|
||||||
Slice subdomain(&host[0], host.size() - 5);
|
Slice subdomain(&host[0], host.size() - 5);
|
||||||
if (is_valid_username(subdomain) && subdomain != "addemoji" && subdomain != "addstickers" &&
|
if (is_valid_username(subdomain) && subdomain != "addemoji" && subdomain != "addlist" &&
|
||||||
subdomain != "addtheme" && subdomain != "auth" && subdomain != "confirmphone" && subdomain != "invoice" &&
|
subdomain != "addstickers" && subdomain != "addtheme" && subdomain != "auth" && subdomain != "confirmphone" &&
|
||||||
subdomain != "joinchat" && subdomain != "list" && subdomain != "login" && subdomain != "proxy" &&
|
subdomain != "invoice" && subdomain != "joinchat" && subdomain != "login" && subdomain != "proxy" &&
|
||||||
subdomain != "setlanguage" && subdomain != "share" && subdomain != "socks" && subdomain != "web" &&
|
subdomain != "setlanguage" && subdomain != "share" && subdomain != "socks" && subdomain != "web" &&
|
||||||
subdomain != "k" && subdomain != "z") {
|
subdomain != "k" && subdomain != "z") {
|
||||||
result.type_ = LinkType::TMe;
|
result.type_ = LinkType::TMe;
|
||||||
@ -1289,10 +1289,10 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_tg_link_query(Slice que
|
|||||||
}
|
}
|
||||||
// settings
|
// settings
|
||||||
return td::make_unique<InternalLinkSettings>();
|
return td::make_unique<InternalLinkSettings>();
|
||||||
} else if (path.size() == 1 && path[0] == "list") {
|
} else if (path.size() == 1 && path[0] == "addlist") {
|
||||||
auto slug = get_url_query_slug(true, url_query);
|
auto slug = get_url_query_slug(true, url_query);
|
||||||
if (!slug.empty() && is_base64url_characters(slug)) {
|
if (!slug.empty() && is_base64url_characters(slug)) {
|
||||||
// list?slug=<slug>
|
// addlist?slug=<slug>
|
||||||
return td::make_unique<InternalLinkDialogFolderInvite>(get_dialog_filter_invite_link(slug, true));
|
return td::make_unique<InternalLinkDialogFolderInvite>(get_dialog_filter_invite_link(slug, true));
|
||||||
}
|
}
|
||||||
} else if (path.size() == 1 && path[0] == "join") {
|
} else if (path.size() == 1 && path[0] == "join") {
|
||||||
@ -1425,10 +1425,10 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_t_me_link_query(Slice q
|
|||||||
// /login/<code>
|
// /login/<code>
|
||||||
return td::make_unique<InternalLinkAuthenticationCode>(path[1]);
|
return td::make_unique<InternalLinkAuthenticationCode>(path[1]);
|
||||||
}
|
}
|
||||||
} else if (path[0] == "list") {
|
} else if (path[0] == "addlist") {
|
||||||
auto slug = get_url_query_slug(false, url_query);
|
auto slug = get_url_query_slug(false, url_query);
|
||||||
if (!slug.empty() && is_base64url_characters(slug)) {
|
if (!slug.empty() && is_base64url_characters(slug)) {
|
||||||
// /list/<slug>
|
// /addlist/<slug>
|
||||||
return td::make_unique<InternalLinkDialogFolderInvite>(get_dialog_filter_invite_link(slug, true));
|
return td::make_unique<InternalLinkDialogFolderInvite>(get_dialog_filter_invite_link(slug, true));
|
||||||
}
|
}
|
||||||
} else if (path[0] == "joinchat") {
|
} else if (path[0] == "joinchat") {
|
||||||
@ -2328,9 +2328,9 @@ string LinkManager::get_dialog_filter_invite_link(Slice slug, bool is_internal)
|
|||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
if (is_internal) {
|
if (is_internal) {
|
||||||
return PSTRING() << "tg:list?slug=" << slug;
|
return PSTRING() << "tg:addlist?slug=" << slug;
|
||||||
} else {
|
} else {
|
||||||
return PSTRING() << get_t_me_url() << "list/" << slug;
|
return PSTRING() << get_t_me_url() << "addlist/" << slug;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ static auto change_phone_number() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static auto chat_folder_invite(const td::string &slug) {
|
static auto chat_folder_invite(const td::string &slug) {
|
||||||
return td::td_api::make_object<td::td_api::internalLinkTypeChatFolderInvite>("tg:list?slug=" + slug);
|
return td::td_api::make_object<td::td_api::internalLinkTypeChatFolderInvite>("tg:addlist?slug=" + slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto chat_folder_settings() {
|
static auto chat_folder_settings() {
|
||||||
@ -707,23 +707,23 @@ TEST(Link, parse_internal_link_part2) {
|
|||||||
parse_internal_link("t.me/+123456?attach=bot&startattach=1",
|
parse_internal_link("t.me/+123456?attach=bot&startattach=1",
|
||||||
attachment_menu_bot(nullptr, user_phone_number("123456"), "bot", "1"));
|
attachment_menu_bot(nullptr, user_phone_number("123456"), "bot", "1"));
|
||||||
|
|
||||||
parse_internal_link("t.me/list?invite=abcdef", nullptr);
|
parse_internal_link("t.me/addlist?invite=abcdef", nullptr);
|
||||||
parse_internal_link("t.me/list", nullptr);
|
parse_internal_link("t.me/addlist", nullptr);
|
||||||
parse_internal_link("t.me/list/", nullptr);
|
parse_internal_link("t.me/addlist/", nullptr);
|
||||||
parse_internal_link("t.me/list//abcdef", nullptr);
|
parse_internal_link("t.me/addlist//abcdef", nullptr);
|
||||||
parse_internal_link("t.me/list?/abcdef", nullptr);
|
parse_internal_link("t.me/addlist?/abcdef", nullptr);
|
||||||
parse_internal_link("t.me/list/?abcdef", nullptr);
|
parse_internal_link("t.me/addlist/?abcdef", nullptr);
|
||||||
parse_internal_link("t.me/list/#abcdef", nullptr);
|
parse_internal_link("t.me/addlist/#abcdef", nullptr);
|
||||||
parse_internal_link("t.me/list/abacaba", chat_folder_invite("abacaba"));
|
parse_internal_link("t.me/addlist/abacaba", chat_folder_invite("abacaba"));
|
||||||
parse_internal_link("t.me/list/aba%20aba", nullptr);
|
parse_internal_link("t.me/addlist/aba%20aba", nullptr);
|
||||||
parse_internal_link("t.me/list/aba%30aba", chat_folder_invite("aba0aba"));
|
parse_internal_link("t.me/addlist/aba%30aba", chat_folder_invite("aba0aba"));
|
||||||
parse_internal_link("t.me/list/123456a", chat_folder_invite("123456a"));
|
parse_internal_link("t.me/addlist/123456a", chat_folder_invite("123456a"));
|
||||||
parse_internal_link("t.me/list/12345678901", chat_folder_invite("12345678901"));
|
parse_internal_link("t.me/addlist/12345678901", chat_folder_invite("12345678901"));
|
||||||
parse_internal_link("t.me/list/123456", chat_folder_invite("123456"));
|
parse_internal_link("t.me/addlist/123456", chat_folder_invite("123456"));
|
||||||
parse_internal_link("t.me/list/123456/123123/12/31/a/s//21w/?asdas#test", chat_folder_invite("123456"));
|
parse_internal_link("t.me/addlist/123456/123123/12/31/a/s//21w/?asdas#test", chat_folder_invite("123456"));
|
||||||
parse_internal_link("t.me/list/12345678901a", chat_folder_invite("12345678901a"));
|
parse_internal_link("t.me/addlist/12345678901a", chat_folder_invite("12345678901a"));
|
||||||
parse_internal_link("t.me/list/123456a", chat_folder_invite("123456a"));
|
parse_internal_link("t.me/addlist/123456a", chat_folder_invite("123456a"));
|
||||||
parse_internal_link("t.me/list/123456a/123123/12/31/a/s//21w/?asdas#test", chat_folder_invite("123456a"));
|
parse_internal_link("t.me/addlist/123456a/123123/12/31/a/s//21w/?asdas#test", chat_folder_invite("123456a"));
|
||||||
|
|
||||||
parse_internal_link("t.me/contact/startattach/adasd", user_token("startattach"));
|
parse_internal_link("t.me/contact/startattach/adasd", user_token("startattach"));
|
||||||
parse_internal_link("t.me/contact/startattach", user_token("startattach"));
|
parse_internal_link("t.me/contact/startattach", user_token("startattach"));
|
||||||
@ -736,10 +736,10 @@ TEST(Link, parse_internal_link_part2) {
|
|||||||
parse_internal_link("tg://join?invite=abc%30def", chat_invite("abc0def"));
|
parse_internal_link("tg://join?invite=abc%30def", chat_invite("abc0def"));
|
||||||
parse_internal_link("tg:join?invite=", unknown_deep_link("tg://join?invite="));
|
parse_internal_link("tg:join?invite=", unknown_deep_link("tg://join?invite="));
|
||||||
|
|
||||||
parse_internal_link("tg:list?slug=abcdef", chat_folder_invite("abcdef"));
|
parse_internal_link("tg:addlist?slug=abcdef", chat_folder_invite("abcdef"));
|
||||||
parse_internal_link("tg:list?slug=abc%20def", unknown_deep_link("tg://list?slug=abc%20def"));
|
parse_internal_link("tg:addlist?slug=abc%20def", unknown_deep_link("tg://addlist?slug=abc%20def"));
|
||||||
parse_internal_link("tg://list?slug=abc%30def", chat_folder_invite("abc0def"));
|
parse_internal_link("tg://addlist?slug=abc%30def", chat_folder_invite("abc0def"));
|
||||||
parse_internal_link("tg:list?slug=", unknown_deep_link("tg://list?slug="));
|
parse_internal_link("tg:addlist?slug=", unknown_deep_link("tg://addlist?slug="));
|
||||||
|
|
||||||
parse_internal_link("t.me/addstickers?set=abcdef", nullptr);
|
parse_internal_link("t.me/addstickers?set=abcdef", nullptr);
|
||||||
parse_internal_link("t.me/addstickers", nullptr);
|
parse_internal_link("t.me/addstickers", nullptr);
|
||||||
@ -1163,13 +1163,13 @@ TEST(Link, parse_internal_link_part4) {
|
|||||||
parse_internal_link("0aaa.t.me/12345?single", nullptr);
|
parse_internal_link("0aaa.t.me/12345?single", nullptr);
|
||||||
parse_internal_link("_aaa.t.me/12345?single", nullptr);
|
parse_internal_link("_aaa.t.me/12345?single", nullptr);
|
||||||
parse_internal_link("addemoji.t.me", nullptr);
|
parse_internal_link("addemoji.t.me", nullptr);
|
||||||
|
parse_internal_link("addlist.t.me", nullptr);
|
||||||
parse_internal_link("addstickers.t.me", nullptr);
|
parse_internal_link("addstickers.t.me", nullptr);
|
||||||
parse_internal_link("addtheme.t.me", nullptr);
|
parse_internal_link("addtheme.t.me", nullptr);
|
||||||
parse_internal_link("auth.t.me", nullptr);
|
parse_internal_link("auth.t.me", nullptr);
|
||||||
parse_internal_link("confirmphone.t.me", nullptr);
|
parse_internal_link("confirmphone.t.me", nullptr);
|
||||||
parse_internal_link("invoice.t.me", nullptr);
|
parse_internal_link("invoice.t.me", nullptr);
|
||||||
parse_internal_link("joinchat.t.me", nullptr);
|
parse_internal_link("joinchat.t.me", nullptr);
|
||||||
parse_internal_link("list.t.me", nullptr);
|
|
||||||
parse_internal_link("login.t.me", nullptr);
|
parse_internal_link("login.t.me", nullptr);
|
||||||
parse_internal_link("proxy.t.me", nullptr);
|
parse_internal_link("proxy.t.me", nullptr);
|
||||||
parse_internal_link("setlanguage.t.me", nullptr);
|
parse_internal_link("setlanguage.t.me", nullptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user