diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index a760bc606..fcaa17f6f 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -513,6 +513,12 @@ bool ResolveUsernameOrPhone( if (domain == u"telegrampassport"_q) { return ShowPassportForm(controller, params); } else if (!validDomain(domain) && !validPhone(phone)) { + const auto searchParam = params.value(qsl("query")); + if (!searchParam.isEmpty()) { + controller->content()->searchMessages( + searchParam + ' ', + Dialogs::Key()); + } return false; } using ResolveType = Window::ResolveType; @@ -598,6 +604,7 @@ bool ResolveUsernameOrPhone( ? std::make_optional(params.value(u"voicechat"_q)) : std::nullopt), .clickFromMessageId = myContext.itemId, + .searchQuery = params.value(qsl("query")), .clickFromAttachBotWebviewUrl = myContext.attachBotWebviewUrl, }); return true; diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 96277655f..7a8432aac 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -614,6 +614,16 @@ void SessionNavigation::showPeerByLinkResolved( : info.resolveType; const auto &replies = info.repliesInfo; + const auto searchQuery = info.searchQuery; + + const auto applySearchQuery = [=] { + parentController()->content()->searchMessages( + searchQuery + ' ', + (peer && !peer->isUser()) + ? peer->owner().history(peer).get() + : Dialogs::Key()); + }; + if (const auto threadId = std::get_if(&replies)) { showRepliesForMessage( session().data().history(peer), @@ -697,6 +707,14 @@ void SessionNavigation::showPeerByLinkResolved( if (bot || peer->isChannel()) { crl::on_main(this, [=] { showPeerHistory(peer, params); + if (!searchQuery.isEmpty()) { + applySearchQuery(); + } + }); + } else if (!searchQuery.isEmpty()) { + crl::on_main(this, [=] { + showPeerHistory(peer, params); + applySearchQuery(); }); } else { showPeerInfo(peer, params); @@ -721,11 +739,15 @@ void SessionNavigation::showPeerByLinkResolved( crl::on_main(this, [=] { const auto history = peer->owner().history(peer); showPeerHistory(history, params, msgId); - peer->session().attachWebView().request( - parentController(), - Api::SendAction(history), - attachBotUsername, - info.attachBotToggleCommand.value_or(QString())); + if (searchQuery.isEmpty()) { + peer->session().attachWebView().request( + parentController(), + Api::SendAction(history), + attachBotUsername, + info.attachBotToggleCommand.value_or(QString())); + } else { + applySearchQuery(); + } }); } else if (bot && info.attachBotMenuOpen) { const auto startCommand = info.attachBotToggleCommand.value_or( @@ -762,6 +784,9 @@ void SessionNavigation::showPeerByLinkResolved( Data::SetChatLinkDraft(peer, { draft }); } showPeerHistory(peer, params, msgId); + if (!searchQuery.isEmpty()) { + applySearchQuery(); + } }); } } diff --git a/Telegram/SourceFiles/window/window_session_controller_link_info.h b/Telegram/SourceFiles/window/window_session_controller_link_info.h index 2c7457122..b16c984ca 100644 --- a/Telegram/SourceFiles/window/window_session_controller_link_info.h +++ b/Telegram/SourceFiles/window/window_session_controller_link_info.h @@ -49,6 +49,7 @@ struct PeerByLinkInfo { InlineBots::PeerTypes attachBotChooseTypes; std::optional voicechatHash; FullMsgId clickFromMessageId; + QString searchQuery; QString clickFromAttachBotWebviewUrl; };