mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-30 01:08:02 +00:00
Support hashtags with mentions.
This commit is contained in:
@@ -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 {};
|
||||
|
||||
@@ -65,6 +65,13 @@ struct MessageReaction {
|
||||
[[nodiscard]] std::vector<ReactionId> SearchTagsFromQuery(
|
||||
const QString &query);
|
||||
|
||||
struct HashtagWithUsername {
|
||||
QString hashtag;
|
||||
QString username;
|
||||
};
|
||||
[[nodiscard]] HashtagWithUsername HashtagWithUsernameFromQuery(
|
||||
QStringView query);
|
||||
|
||||
[[nodiscard]] QString ReactionEntityData(const ReactionId &id);
|
||||
|
||||
[[nodiscard]] ReactionId ReactionFromMTP(const MTPReaction &reaction);
|
||||
|
||||
Reference in New Issue
Block a user