Add internalLinkTypeVoiceChat.is_live_stream flag.

This commit is contained in:
levlam 2021-09-08 13:53:24 +03:00
parent 015d6cd92d
commit 1c56e62a6a
3 changed files with 25 additions and 21 deletions

View File

@ -3180,7 +3180,8 @@ internalLinkTypeUnknownDeepLink link:string = InternalLinkType;
//@description The link is a link to a voice chat. Call searchPublicChat with the given chat username, and then joinGoupCall with the given invite hash to process the link //@description The link is a link to a voice chat. Call searchPublicChat with the given chat username, and then joinGoupCall with the given invite hash to process the link
//@chat_username Username of the chat with the voice chat @invite_hash If non-empty, invite hash to be used to join the voice chat without being muted by administrators //@chat_username Username of the chat with the voice chat @invite_hash If non-empty, invite hash to be used to join the voice chat without being muted by administrators
internalLinkTypeVoiceChat chat_username:string invite_hash:string = InternalLinkType; //@is_live_stream True, if the voice chat is expected to be a live stream in a channel or a broadcast group
internalLinkTypeVoiceChat chat_username:string invite_hash:string is_live_stream:Bool = InternalLinkType;
//@description Contains an HTTPS link to a message in a supergroup or channel @link Message link @is_public True, if the link will work for non-members of the chat //@description Contains an HTTPS link to a message in a supergroup or channel @link Message link @is_public True, if the link will work for non-members of the chat

View File

@ -357,14 +357,17 @@ class LinkManager::InternalLinkUnknownDeepLink final : public InternalLink {
class LinkManager::InternalLinkVoiceChat final : public InternalLink { class LinkManager::InternalLinkVoiceChat final : public InternalLink {
string dialog_username_; string dialog_username_;
string invite_hash_; string invite_hash_;
bool is_live_stream_;
td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final { td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final {
return td_api::make_object<td_api::internalLinkTypeVoiceChat>(dialog_username_, invite_hash_); return td_api::make_object<td_api::internalLinkTypeVoiceChat>(dialog_username_, invite_hash_, is_live_stream_);
} }
public: public:
InternalLinkVoiceChat(string dialog_username, string invite_hash) InternalLinkVoiceChat(string dialog_username, string invite_hash, bool is_live_stream)
: dialog_username_(std::move(dialog_username)), invite_hash_(std::move(invite_hash)) { : dialog_username_(std::move(dialog_username))
, invite_hash_(std::move(invite_hash))
, is_live_stream_(is_live_stream) {
} }
}; };
@ -774,7 +777,7 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_tg_link_query(Slice que
if (Scheduler::context() != nullptr) { if (Scheduler::context() != nullptr) {
send_closure(G()->messages_manager(), &MessagesManager::reload_voice_chat_on_search, username); send_closure(G()->messages_manager(), &MessagesManager::reload_voice_chat_on_search, username);
} }
return td::make_unique<InternalLinkVoiceChat>(std::move(username), arg.second); return td::make_unique<InternalLinkVoiceChat>(std::move(username), arg.second, arg.first == "livestream");
} }
if (arg.first == "start" && is_valid_start_parameter(arg.second)) { if (arg.first == "start" && is_valid_start_parameter(arg.second)) {
// resolve?domain=<bot_username>?start=<parameter> // resolve?domain=<bot_username>?start=<parameter>
@ -1023,7 +1026,7 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_t_me_link_query(Slice q
if (Scheduler::context() != nullptr) { if (Scheduler::context() != nullptr) {
send_closure(G()->messages_manager(), &MessagesManager::reload_voice_chat_on_search, username); send_closure(G()->messages_manager(), &MessagesManager::reload_voice_chat_on_search, username);
} }
return td::make_unique<InternalLinkVoiceChat>(std::move(username), arg.second); return td::make_unique<InternalLinkVoiceChat>(std::move(username), arg.second, arg.first == "livestream");
} }
if (arg.first == "start" && is_valid_start_parameter(arg.second)) { if (arg.first == "start" && is_valid_start_parameter(arg.second)) {
// /<bot_username>?start=<parameter> // /<bot_username>?start=<parameter>

View File

@ -170,8 +170,8 @@ TEST(Link, parse_internal_link) {
auto unknown_deep_link = [](td::string link) { auto unknown_deep_link = [](td::string link) {
return td::td_api::make_object<td::td_api::internalLinkTypeUnknownDeepLink>(link); return td::td_api::make_object<td::td_api::internalLinkTypeUnknownDeepLink>(link);
}; };
auto voice_chat = [](td::string chat_username, td::string invite_hash) { auto voice_chat = [](td::string chat_username, td::string invite_hash, bool is_live_stream) {
return td::td_api::make_object<td::td_api::internalLinkTypeVoiceChat>(chat_username, invite_hash); return td::td_api::make_object<td::td_api::internalLinkTypeVoiceChat>(chat_username, invite_hash, is_live_stream);
}; };
parse_internal_link("t.me/levlam/1", message("tg:resolve?domain=levlam&post=1")); parse_internal_link("t.me/levlam/1", message("tg:resolve?domain=levlam&post=1"));
@ -523,27 +523,27 @@ TEST(Link, parse_internal_link) {
parse_internal_link("tg:socks?server=google.com&port=8%30&user=&pass=2", proxy_socks("google.com", 80, "", "2")); parse_internal_link("tg:socks?server=google.com&port=8%30&user=&pass=2", proxy_socks("google.com", 80, "", "2"));
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: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&voice%63hat=aasdasd", voice_chat("username", "aasdasd", false));
parse_internal_link("tg:resolve?domain=username&video%63hat=aasdasd", voice_chat("username", "aasdasd")); parse_internal_link("tg:resolve?domain=username&video%63hat=aasdasd", voice_chat("username", "aasdasd", false));
parse_internal_link("tg:resolve?domain=username&livestream=aasdasd", voice_chat("username", "aasdasd")); parse_internal_link("tg:resolve?domain=username&livestream=aasdasd", voice_chat("username", "aasdasd", true));
parse_internal_link("TG://resolve?domain=username&voicechat=", voice_chat("username", "")); parse_internal_link("TG://resolve?domain=username&voicechat=", voice_chat("username", "", false));
parse_internal_link("TG://test@resolve?domain=username&voicechat=", nullptr); parse_internal_link("TG://test@resolve?domain=username&voicechat=", nullptr);
parse_internal_link("tg:resolve:80?domain=username&voicechat=", nullptr); parse_internal_link("tg:resolve:80?domain=username&voicechat=", nullptr);
parse_internal_link("tg:http://resolve?domain=username&voicechat=", nullptr); parse_internal_link("tg:http://resolve?domain=username&voicechat=", nullptr);
parse_internal_link("tg:https://resolve?domain=username&voicechat=", nullptr); parse_internal_link("tg:https://resolve?domain=username&voicechat=", nullptr);
parse_internal_link("tg:resolve?domain=&voicechat=", unknown_deep_link("tg://resolve?domain=&voicechat=")); parse_internal_link("tg:resolve?domain=&voicechat=", unknown_deep_link("tg://resolve?domain=&voicechat="));
parse_internal_link("tg:resolve?domain=telegram&&&&&&&voicechat=%30", voice_chat("telegram", "0")); parse_internal_link("tg:resolve?domain=telegram&&&&&&&voicechat=%30", voice_chat("telegram", "0", false));
parse_internal_link("t.me/username/0/a//s/as?voicechat=", voice_chat("username", "")); parse_internal_link("t.me/username/0/a//s/as?voicechat=", voice_chat("username", "", false));
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?videochat=2", voice_chat("username", "2", false));
parse_internal_link("t.me/username/0/a//s/as?livestream=3", voice_chat("username", "3")); parse_internal_link("t.me/username/0/a//s/as?livestream=3", voice_chat("username", "3", true));
parse_internal_link("t.me/username/aasdas?test=1&voicechat=#12312", voice_chat("username", "")); parse_internal_link("t.me/username/aasdas?test=1&voicechat=#12312", voice_chat("username", "", false));
parse_internal_link("t.me/username/0?voicechat=", voice_chat("username", "")); parse_internal_link("t.me/username/0?voicechat=", voice_chat("username", "", false));
parse_internal_link("t.me/username/-1?voicechat=asdasd", voice_chat("username", "asdasd")); parse_internal_link("t.me/username/-1?voicechat=asdasd", voice_chat("username", "asdasd", false));
parse_internal_link("t.me/username?voicechat=", voice_chat("username", "")); parse_internal_link("t.me/username?voicechat=", voice_chat("username", "", false));
parse_internal_link("t.me/username#voicechat=asdas", public_chat("username")); parse_internal_link("t.me/username#voicechat=asdas", public_chat("username"));
parse_internal_link("t.me//username?voicechat=", nullptr); parse_internal_link("t.me//username?voicechat=", nullptr);
parse_internal_link("https://telegram.dog/tele%63ram?voi%63e%63hat=t%63st", voice_chat("telecram", "tcst")); parse_internal_link("https://telegram.dog/tele%63ram?voi%63e%63hat=t%63st", voice_chat("telecram", "tcst", false));
parse_internal_link("tg:resolve?domain=username&start=aasdasd", bot_start("username", "aasdasd")); parse_internal_link("tg:resolve?domain=username&start=aasdasd", bot_start("username", "aasdasd"));
parse_internal_link("TG://resolve?domain=username&start=", bot_start("username", "")); parse_internal_link("TG://resolve?domain=username&start=", bot_start("username", ""));