diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 3bc352ace..95de127cb 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -380,6 +380,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; @@ -464,6 +470,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 a5a84cf28..f9f86bf00 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -519,6 +519,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), @@ -602,6 +612,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); @@ -626,11 +644,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( @@ -663,6 +685,9 @@ void SessionNavigation::showPeerByLinkResolved( } else { crl::on_main(this, [=] { 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 927185e5a..c62b7a8d0 100644 --- a/Telegram/SourceFiles/window/window_session_controller_link_info.h +++ b/Telegram/SourceFiles/window/window_session_controller_link_info.h @@ -46,6 +46,7 @@ struct PeerByLinkInfo { InlineBots::PeerTypes attachBotChooseTypes; std::optional voicechatHash; FullMsgId clickFromMessageId; + QString searchQuery; QString clickFromAttachBotWebviewUrl; };