Skip to content

Commit

Permalink
Support videochat/livestream internal links.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Sep 7, 2021
1 parent 5bb10b4 commit 015d6cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions td/telegram/LinkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions test/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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"));
Expand Down

0 comments on commit 015d6cd

Please sign in to comment.