mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Extract username from t.me/username searches.
This commit is contained in:
@@ -23,7 +23,7 @@ using Key = details::SingleMessageSearchKey;
|
||||
|
||||
Key ExtractKey(const QString &query) {
|
||||
const auto trimmed = query.trimmed();
|
||||
const auto local = Core::TryConvertUrlToLocal(query);
|
||||
const auto local = Core::TryConvertUrlToLocal(trimmed);
|
||||
const auto check = local.isEmpty() ? trimmed : local;
|
||||
const auto parse = [&] {
|
||||
const auto delimeter = check.indexOf('?');
|
||||
@@ -216,4 +216,20 @@ std::optional<HistoryItem*> SingleMessageSearch::performLookup(
|
||||
return performLookupById(channelId, ready);
|
||||
}
|
||||
|
||||
QString ConvertPeerSearchQuery(const QString &query) {
|
||||
const auto trimmed = query.trimmed();
|
||||
const auto local = Core::TryConvertUrlToLocal(trimmed);
|
||||
const auto check = local.isEmpty() ? trimmed : local;
|
||||
if (!check.startsWith(qstr("tg://resolve"), Qt::CaseInsensitive)) {
|
||||
return query;
|
||||
}
|
||||
const auto delimeter = check.indexOf('?');
|
||||
const auto params = (delimeter > 0)
|
||||
? qthelp::url_parse_params(
|
||||
check.mid(delimeter + 1),
|
||||
qthelp::UrlParamNameTransform::ToLower)
|
||||
: QMap<QString, QString>();
|
||||
return params.value("domain", query);
|
||||
}
|
||||
|
||||
} // namespace Api
|
||||
|
@@ -71,4 +71,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
[[nodiscard]] QString ConvertPeerSearchQuery(const QString &query);
|
||||
|
||||
} // namespace Api
|
||||
|
Reference in New Issue
Block a user