Reload voice chat when user opens a voice chat link.
This commit is contained in:
parent
d77220c8ac
commit
126a20c318
@ -654,31 +654,35 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_tg_link_query(Slice que
|
||||
// resolve?domain=<username>&post=12345&single
|
||||
return td::make_unique<InternalLinkMessage>();
|
||||
}
|
||||
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>
|
||||
return td::make_unique<InternalLinkVoiceChat>(get_arg("domain"), arg.second);
|
||||
if (Scheduler::context() != nullptr) {
|
||||
send_closure(G()->messages_manager(), &MessagesManager::reload_voice_chat_on_search, username);
|
||||
}
|
||||
return td::make_unique<InternalLinkVoiceChat>(std::move(username), arg.second);
|
||||
}
|
||||
if (arg.first == "start" && is_valid_start_parameter(arg.second)) {
|
||||
// resolve?domain=<bot_username>?start=<parameter>
|
||||
return td::make_unique<InternalLinkBotStart>(get_arg("domain"), arg.second);
|
||||
return td::make_unique<InternalLinkBotStart>(std::move(username), arg.second);
|
||||
}
|
||||
if (arg.first == "startgroup" && is_valid_start_parameter(arg.second)) {
|
||||
// resolve?domain=<bot_username>?startgroup=<parameter>
|
||||
return td::make_unique<InternalLinkBotStartInGroup>(get_arg("domain"), arg.second);
|
||||
return td::make_unique<InternalLinkBotStartInGroup>(std::move(username), arg.second);
|
||||
}
|
||||
if (arg.first == "game" && !arg.second.empty()) {
|
||||
// resolve?domain=<bot_username>?game=<short_name>
|
||||
return td::make_unique<InternalLinkGame>(get_arg("domain"), arg.second);
|
||||
return td::make_unique<InternalLinkGame>(std::move(username), arg.second);
|
||||
}
|
||||
}
|
||||
if (get_arg("domain") == "telegrampassport") {
|
||||
if (username == "telegrampassport") {
|
||||
// resolve?domain=telegrampassport&bot_id=<bot_user_id>&scope=<scope>&public_key=<public_key>&nonce=<nonce>
|
||||
return get_internal_link_passport(url_query.args_);
|
||||
}
|
||||
// resolve?domain=<username>
|
||||
return td::make_unique<InternalLinkPublicDialog>(get_arg("domain"));
|
||||
return td::make_unique<InternalLinkPublicDialog>(std::move(username));
|
||||
}
|
||||
} else if (path.size() == 1 && path[0] == "login") {
|
||||
// login?code=123456
|
||||
@ -887,27 +891,31 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_t_me_link_query(Slice q
|
||||
// /<username>/12345?single&thread=<thread_id>&comment=<message_id>
|
||||
return td::make_unique<InternalLinkMessage>();
|
||||
}
|
||||
auto username = path[0];
|
||||
for (auto &arg : url_query.args_) {
|
||||
if (arg.first == "voicechat") {
|
||||
// /<username>?voicechat
|
||||
// /<username>?voicechat=<invite_hash>
|
||||
return td::make_unique<InternalLinkVoiceChat>(path[0], arg.second);
|
||||
if (Scheduler::context() != nullptr) {
|
||||
send_closure(G()->messages_manager(), &MessagesManager::reload_voice_chat_on_search, username);
|
||||
}
|
||||
return td::make_unique<InternalLinkVoiceChat>(std::move(username), arg.second);
|
||||
}
|
||||
if (arg.first == "start" && is_valid_start_parameter(arg.second)) {
|
||||
// /<bot_username>?start=<parameter>
|
||||
return td::make_unique<InternalLinkBotStart>(path[0], arg.second);
|
||||
return td::make_unique<InternalLinkBotStart>(std::move(username), arg.second);
|
||||
}
|
||||
if (arg.first == "startgroup" && is_valid_start_parameter(arg.second)) {
|
||||
// /<bot_username>?startgroup=<parameter>
|
||||
return td::make_unique<InternalLinkBotStartInGroup>(path[0], arg.second);
|
||||
return td::make_unique<InternalLinkBotStartInGroup>(std::move(username), arg.second);
|
||||
}
|
||||
if (arg.first == "game" && !arg.second.empty()) {
|
||||
// /<bot_username>?game=<short_name>
|
||||
return td::make_unique<InternalLinkGame>(path[0], arg.second);
|
||||
return td::make_unique<InternalLinkGame>(std::move(username), arg.second);
|
||||
}
|
||||
}
|
||||
// /<username>
|
||||
return td::make_unique<InternalLinkPublicDialog>(path[0]);
|
||||
return td::make_unique<InternalLinkPublicDialog>(std::move(username));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -29717,6 +29717,15 @@ DialogId MessagesManager::search_public_dialog(const string &username_to_search,
|
||||
|
||||
if (dialog_id.is_valid()) {
|
||||
if (have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
if (!force && reload_voice_chat_on_search_usernames_.count(username)) {
|
||||
reload_voice_chat_on_search_usernames_.erase(username);
|
||||
if (dialog_id.get_type() == DialogType::Channel) {
|
||||
td_->contacts_manager_->reload_channel_full(dialog_id.get_channel_id(), std::move(promise),
|
||||
"search_public_dialog");
|
||||
return DialogId();
|
||||
}
|
||||
}
|
||||
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
force_create_dialog(dialog_id, "search_public_dialog", true);
|
||||
} else {
|
||||
@ -29743,6 +29752,10 @@ DialogId MessagesManager::search_public_dialog(const string &username_to_search,
|
||||
return DialogId();
|
||||
}
|
||||
|
||||
void MessagesManager::reload_voice_chat_on_search(const string &username) {
|
||||
reload_voice_chat_on_search_usernames_.insert(clean_username(username));
|
||||
}
|
||||
|
||||
void MessagesManager::send_get_dialog_notification_settings_query(DialogId dialog_id, Promise<Unit> &&promise) {
|
||||
if (td_->auth_manager_->is_bot() || dialog_id.get_type() == DialogType::SecretChat) {
|
||||
LOG(WARNING) << "Can't get notification settings for " << dialog_id;
|
||||
|
@ -364,6 +364,8 @@ class MessagesManager : public Actor {
|
||||
|
||||
DialogId search_public_dialog(const string &username_to_search, bool force, Promise<Unit> &&promise);
|
||||
|
||||
void reload_voice_chat_on_search(const string &username);
|
||||
|
||||
Result<MessageId> send_message(
|
||||
DialogId dialog_id, MessageId top_thread_message_id, MessageId reply_to_message_id,
|
||||
tl_object_ptr<td_api::messageSendOptions> &&options, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
||||
@ -3243,6 +3245,7 @@ class MessagesManager : public Actor {
|
||||
|
||||
std::unordered_map<string, ResolvedUsername> resolved_usernames_;
|
||||
std::unordered_map<string, DialogId> inaccessible_resolved_usernames_;
|
||||
std::unordered_set<string> reload_voice_chat_on_search_usernames_;
|
||||
|
||||
struct PendingOnGetDialogs {
|
||||
FolderId folder_id;
|
||||
|
@ -887,7 +887,7 @@ class SearchPublicChatRequest : public RequestActor<> {
|
||||
public:
|
||||
SearchPublicChatRequest(ActorShared<Td> td, uint64 request_id, string username)
|
||||
: RequestActor(std::move(td), request_id), username_(std::move(username)) {
|
||||
set_tries(3);
|
||||
set_tries(4); // 1 for server request + 1 for reload voice chat + 1 for reload dialog + 1 for result
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user