Support videochat/livestream internal links.

This commit is contained in:
levlam 2021-09-08 01:50:49 +03:00
parent 5bb10b4bb3
commit 015d6cd92d
2 changed files with 10 additions and 6 deletions

View File

@ -768,9 +768,9 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_tg_link_query(Slice que
}
auto username = get_arg("domain");
for (auto &arg : url_query.args_) {
if (arg.first == "voicechat") {
// resolve?domain=<username>&voicechat
// resolve?domain=<username>&voicechat=<invite_hash>
if (arg.first == "voicechat" || arg.first == "videochat" || arg.first == "livestream") {
// resolve?domain=<username>&videochat
// resolve?domain=<username>&videochat=<invite_hash>
if (Scheduler::context() != nullptr) {
send_closure(G()->messages_manager(), &MessagesManager::reload_voice_chat_on_search, username);
}
@ -1017,9 +1017,9 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_t_me_link_query(Slice q
}
auto username = path[0];
for (auto &arg : url_query.args_) {
if (arg.first == "voicechat") {
// /<username>?voicechat
// /<username>?voicechat=<invite_hash>
if (arg.first == "voicechat" || arg.first == "videochat" || arg.first == "livestream") {
// /<username>?videochat
// /<username>?videochat=<invite_hash>
if (Scheduler::context() != nullptr) {
send_closure(G()->messages_manager(), &MessagesManager::reload_voice_chat_on_search, username);
}

View File

@ -524,6 +524,8 @@ TEST(Link, parse_internal_link) {
parse_internal_link("tg:socks?server=google.com&port=80&user=1&pass=2", proxy_socks("google.com", 80, "1", "2"));
parse_internal_link("tg:resolve?domain=username&voice%63hat=aasdasd", voice_chat("username", "aasdasd"));
parse_internal_link("tg:resolve?domain=username&video%63hat=aasdasd", voice_chat("username", "aasdasd"));
parse_internal_link("tg:resolve?domain=username&livestream=aasdasd", voice_chat("username", "aasdasd"));
parse_internal_link("TG://resolve?domain=username&voicechat=", voice_chat("username", ""));
parse_internal_link("TG://test@resolve?domain=username&voicechat=", nullptr);
parse_internal_link("tg:resolve:80?domain=username&voicechat=", nullptr);
@ -533,6 +535,8 @@ TEST(Link, parse_internal_link) {
parse_internal_link("tg:resolve?domain=telegram&&&&&&&voicechat=%30", voice_chat("telegram", "0"));
parse_internal_link("t.me/username/0/a//s/as?voicechat=", voice_chat("username", ""));
parse_internal_link("t.me/username/0/a//s/as?videochat=2", voice_chat("username", "2"));
parse_internal_link("t.me/username/0/a//s/as?livestream=3", voice_chat("username", "3"));
parse_internal_link("t.me/username/aasdas?test=1&voicechat=#12312", voice_chat("username", ""));
parse_internal_link("t.me/username/0?voicechat=", voice_chat("username", ""));
parse_internal_link("t.me/username/-1?voicechat=asdasd", voice_chat("username", "asdasd"));