[Improvement] Query parameter for tg://resolve links

This commit is contained in:
Eric Kotato 2022-09-11 06:19:58 +03:00
parent a3791e5e31
commit 19eba9a676
2 changed files with 29 additions and 0 deletions

View file

@ -271,6 +271,12 @@ bool ResolveUsername(
if (domain == qsl("telegrampassport")) { if (domain == qsl("telegrampassport")) {
return ShowPassportForm(controller, params); return ShowPassportForm(controller, params);
} else if (!valid(domain)) { } else if (!valid(domain)) {
const auto searchParam = params.value(qsl("query"));
if (!searchParam.isEmpty()) {
controller->content()->searchMessages(
searchParam + ' ',
Dialogs::Key());
}
return false; return false;
} }
auto start = qsl("start"); auto start = qsl("start");
@ -321,6 +327,7 @@ bool ResolveUsername(
? std::make_optional(params.value(u"voicechat"_q)) ? std::make_optional(params.value(u"voicechat"_q))
: std::nullopt), : std::nullopt),
.clickFromMessageId = fromMessageId, .clickFromMessageId = fromMessageId,
.searchQuery = params.value(qsl("query")),
}); });
return true; return true;
} }

View file

@ -361,6 +361,7 @@ void SessionNavigation::showPeerByLinkResolved(
return; return;
} }
const auto &replies = info.repliesInfo; const auto &replies = info.repliesInfo;
const auto searchQuery = info.searchQuery;
if (const auto threadId = std::get_if<ThreadId>(&replies)) { if (const auto threadId = std::get_if<ThreadId>(&replies)) {
showRepliesForMessage( showRepliesForMessage(
session().data().history(peer), session().data().history(peer),
@ -395,9 +396,23 @@ void SessionNavigation::showPeerByLinkResolved(
// Always open bot chats, even from mention links. // Always open bot chats, even from mention links.
crl::on_main(this, [=] { crl::on_main(this, [=] {
showPeerHistory(peer->id, params); showPeerHistory(peer->id, params);
if (!searchQuery.isEmpty()) {
parentController()->content()->searchMessages(
searchQuery + ' ',
(peer && !peer->isUser())
? peer->owner().history(peer).get()
: Dialogs::Key());
}
}); });
} else { } else {
showPeerInfo(peer, params); showPeerInfo(peer, params);
if (!searchQuery.isEmpty()) {
parentController()->content()->searchMessages(
searchQuery + ' ',
(peer && !peer->isUser())
? peer->owner().history(peer).get()
: Dialogs::Key());
}
} }
} else { } else {
const auto user = peer->asUser(); const auto user = peer->asUser();
@ -414,6 +429,13 @@ void SessionNavigation::showPeerByLinkResolved(
} }
crl::on_main(this, [=] { crl::on_main(this, [=] {
showPeerHistory(peer->id, params, msgId); showPeerHistory(peer->id, params, msgId);
if (!searchQuery.isEmpty()) {
parentController()->content()->searchMessages(
searchQuery + ' ',
(peer && !peer->isUser())
? peer->owner().history(peer).get()
: Dialogs::Key());
}
}); });
} }
} }