From 2dfa40e017c9880164936b50a0ab698dd83a125b Mon Sep 17 00:00:00 2001 From: targetakhil Date: Sun, 18 Apr 2021 11:22:44 +0530 Subject: strip reply fallbacks from forwarded message --- src/timeline/TimelineViewManager.h | 45 +++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) (limited to 'src/timeline/TimelineViewManager.h') diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index e5dea7ce..7e9632de 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -13,7 +13,6 @@ #include #include #include -#include #include "Cache.h" #include "CallManager.h" @@ -159,15 +158,51 @@ private: typename nheko::detail::detector::value_t; template - using f_t = decltype(Content::file); + using file_t = decltype(Content::file); template - using u_t = decltype(Content::url); + using url_t = decltype(Content::url); + + template + using body_t = decltype(Content::body); + + template + using formatted_body_t = decltype(Content::formatted_body); + + template + static constexpr bool messageWithFileAndUrl(const mtx::events::Event &) + { + return is_detected::value && is_detected::value; + } template - static constexpr bool messageWithFileAndUrl(const mtx::events::Event &e) + static constexpr void removeReplyFallback(mtx::events::Event &e) { - return is_detected::value && is_detected::value; + if constexpr (is_detected::value) { + 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(); + } + } 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(); + } + } + + 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(); + } + } } private: -- cgit 1.5.1