summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authortargetakhil <targetakhil@gmail.com>2021-04-18 12:03:25 +0530
committertargetakhil <targetakhil@gmail.com>2021-04-18 12:03:25 +0530
commit5a5aba662e21f468733d1ee1bb2023a6ca3d433d (patch)
tree5754174384814a122e90ec8cba9f35ac219073a7 /src
parentstrip reply fallbacks from forwarded message (diff)
downloadnheko-5a5aba662e21f468733d1ee1bb2023a6ca3d433d.tar.xz
make util strip util functions non-static and move definition to cpp file
Diffstat (limited to 'src')
-rw-r--r--src/Utils.cpp18
-rw-r--r--src/Utils.h20
2 files changed, 22 insertions, 16 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp

index 11e7b1af..43d94151 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp
@@ -52,6 +52,24 @@ createDescriptionInfo(const Event &event, const QString &localUser, const QStrin ts}; } +void +utils::stripReplyFromBody(QString &body) +{ + QRegularExpression plainQuote("^>.*?$\n?", QRegularExpression::MultilineOption); + while (body.startsWith(">")) + body.remove(plainQuote); + if (body.startsWith("\n")) + body.remove(0, 1); +} + +void +utils::stripReplyFromFormattedBody(QString &formatted_body) +{ + formatted_body.remove(QRegularExpression("<mx-reply>.*</mx-reply>", + QRegularExpression::DotMatchesEverythingOption)); + formatted_body.replace("@room", "@\u2060aroom"); +} + RelatedInfo utils::stripReplyFallbacks(const TimelineEvent &event, std::string id, QString room_id_) { diff --git a/src/Utils.h b/src/Utils.h
index e62b2d34..f5d02237 100644 --- a/src/Utils.h +++ b/src/Utils.h
@@ -42,24 +42,12 @@ namespace utils { using TimelineEvent = mtx::events::collections::TimelineEvents; //! Helper function to remove reply fallback from body -static void -stripReplyFromBody(QString &body) -{ - QRegularExpression plainQuote("^>.*?$\n?", QRegularExpression::MultilineOption); - while (body.startsWith(">")) - body.remove(plainQuote); - if (body.startsWith("\n")) - body.remove(0, 1); -} +void +stripReplyFromBody(QString &body); //! Helper function to remove reply fallback from formatted body -static void -stripReplyFromFormattedBody(QString &formatted_body) -{ - formatted_body.remove(QRegularExpression("<mx-reply>.*</mx-reply>", - QRegularExpression::DotMatchesEverythingOption)); - formatted_body.replace("@room", "@\u2060aroom"); -} +void +stripReplyFromFormattedBody(QString &formatted_body); RelatedInfo stripReplyFallbacks(const TimelineEvent &event, std::string id, QString room_id_);