diff --git a/src/Utils.cpp b/src/Utils.cpp
index 43d94151..d6ebc754 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -52,22 +52,26 @@ createDescriptionInfo(const Event &event, const QString &localUser, const QStrin
ts};
}
-void
-utils::stripReplyFromBody(QString &body)
+std::string
+utils::stripReplyFromBody(const std::string &bodyi)
{
+ QString body = QString::fromStdString(bodyi);
QRegularExpression plainQuote("^>.*?$\n?", QRegularExpression::MultilineOption);
while (body.startsWith(">"))
body.remove(plainQuote);
if (body.startsWith("\n"))
body.remove(0, 1);
+ return body.toStdString();
}
-void
-utils::stripReplyFromFormattedBody(QString &formatted_body)
+std::string
+utils::stripReplyFromFormattedBody(const std::string &formatted_bodyi)
{
+ QString formatted_body = QString::fromStdString(formatted_bodyi);
formatted_body.remove(QRegularExpression(".*",
QRegularExpression::DotMatchesEverythingOption));
formatted_body.replace("@room", "@\u2060aroom");
+ return formatted_body.toStdString();
}
RelatedInfo
@@ -81,13 +85,15 @@ utils::stripReplyFallbacks(const TimelineEvent &event, std::string id, QString r
// get body, strip reply fallback, then transform the event to text, if it is a media event
// etc
related.quoted_body = QString::fromStdString(mtx::accessors::body(event));
- stripReplyFromBody(related.quoted_body);
+ related.quoted_body =
+ QString::fromStdString(stripReplyFromBody(related.quoted_body.toStdString()));
related.quoted_body = utils::getQuoteBody(related);
related.quoted_body.replace("@room", QString::fromUtf8("@\u2060room"));
// get quoted body and strip reply fallback
related.quoted_formatted_body = mtx::accessors::formattedBodyWithFallback(event);
- stripReplyFromFormattedBody(related.quoted_formatted_body);
+ related.quoted_formatted_body = QString::fromStdString(
+ stripReplyFromFormattedBody(related.quoted_formatted_body.toStdString()));
related.room = room_id_;
return related;
diff --git a/src/Utils.h b/src/Utils.h
index f5d02237..e976cf81 100644
--- a/src/Utils.h
+++ b/src/Utils.h
@@ -42,12 +42,12 @@ namespace utils {
using TimelineEvent = mtx::events::collections::TimelineEvents;
//! Helper function to remove reply fallback from body
-void
-stripReplyFromBody(QString &body);
+std::string
+stripReplyFromBody(const std::string &body);
//! Helper function to remove reply fallback from formatted body
-void
-stripReplyFromFormattedBody(QString &formatted_body);
+std::string
+stripReplyFromFormattedBody(const std::string &formatted_body);
RelatedInfo
stripReplyFallbacks(const TimelineEvent &event, std::string id, QString room_id_);
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index ff759625..d89f4a1b 100644
--- a/src/timeline/TimelineViewManager.cpp
+++ b/src/timeline/TimelineViewManager.cpp
@@ -632,9 +632,8 @@ TimelineViewManager::forwardMessageToRoom(mtx::events::collections::TimelineEven
const std::string &content_type,
const std::string &originalFilename,
mtx::http::RequestErr err) {
- if (err) {
+ if (err)
return;
- }
auto data = mtx::crypto::to_string(
mtx::crypto::decrypt_file(res, encryptionInfo.value()));
@@ -654,7 +653,7 @@ TimelineViewManager::forwardMessageToRoom(mtx::events::collections::TimelineEven
}
std::visit(
- [this, roomId, e, url = res.content_uri](auto ev) {
+ [this, roomId, url = res.content_uri](auto ev) {
if constexpr (mtx::events::message_content_to_type<
decltype(ev.content)> ==
mtx::events::EventType::RoomMessage) {
diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h
index 7e9632de..809b286e 100644
--- a/src/timeline/TimelineViewManager.h
+++ b/src/timeline/TimelineViewManager.h
@@ -182,25 +182,19 @@ private:
if constexpr (std::is_same_v,
std::remove_cv_t>) {
if (e.content.body) {
- QString body = QString::fromStdString(e.content.body);
- utils::stripReplyFromBody(body);
- e.content.body = body.toStdString();
+ e.content.body = utils::stripReplyFromBody(e.content.body);
}
} else if constexpr (std::is_same_v<
std::string,
std::remove_cv_t>) {
- QString body = QString::fromStdString(e.content.body);
- utils::stripReplyFromBody(body);
- e.content.body = body.toStdString();
+ e.content.body = utils::stripReplyFromBody(e.content.body);
}
}
if constexpr (is_detected::value) {
if (e.content.format == "org.matrix.custom.html") {
- QString formattedBody =
- QString::fromStdString(e.content.formatted_body);
- utils::stripReplyFromFormattedBody(formattedBody);
- e.content.formatted_body = formattedBody.toStdString();
+ e.content.formatted_body =
+ utils::stripReplyFromFormattedBody(e.content.formatted_body);
}
}
}