Support hashtags with mentions.

This commit is contained in:
John Preston
2024-10-11 09:31:03 +04:00
parent f89aeb6ad4
commit 7ee2e3d8bc
6 changed files with 42 additions and 1 deletions
@@ -40,6 +40,25 @@ std::vector<ReactionId> SearchTagsFromQuery(
return result;
}
HashtagWithUsername HashtagWithUsernameFromQuery(QStringView query) {
const auto match = TextUtilities::RegExpHashtag(true).match(query);
if (match.hasMatch()) {
const auto username = match.capturedView(2).mid(1).toString();
const auto offset = int(match.capturedLength(1));
const auto full = int(query.size());
const auto length = full
- int(username.size())
- 1
- offset
- int(match.capturedLength(3));
if (!username.isEmpty() && length > 0 && offset + length <= full) {
const auto hashtag = query.mid(offset, length).toString();
return { hashtag, username };
}
}
return {};
}
QString ReactionEntityData(const ReactionId &id) {
if (id.empty()) {
return {};