summary refs log tree commit diff
path: root/src/notifications/ManagerWin.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-03-17 19:08:17 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-03-17 19:18:07 +0100
commite5d75c814b2175dc37beabff3b0421de59a3e93e (patch)
tree97670bfa02e365ef527ad18fad3d66e16c3ef8d2 /src/notifications/ManagerWin.cpp
parentRefactor image download code to be reusable (diff)
downloadnheko-e5d75c814b2175dc37beabff3b0421de59a3e93e.tar.xz
Clean up notification code a bit
Diffstat (limited to 'src/notifications/ManagerWin.cpp')
-rw-r--r--src/notifications/ManagerWin.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/notifications/ManagerWin.cpp b/src/notifications/ManagerWin.cpp
index baafb6dc..d37bff67 100644
--- a/src/notifications/ManagerWin.cpp
+++ b/src/notifications/ManagerWin.cpp
@@ -108,20 +108,11 @@ NotificationsManager::formatNotification(const mtx::responses::Notification &not
           cache::displayName(QString::fromStdString(notification.room_id),
                              QString::fromStdString(mtx::accessors::sender(notification.event)));
 
-        const auto messageLeadIn =
-          ((mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Emote)
-             ? "* " + sender + " "
-             : sender +
-                 (utils::isReply(notification.event)
-                    ? tr(" replied",
-                         "Used to denote that this message is a reply to another "
-                         "message. Displayed as 'foo replied: message'.")
-                    : "") +
-                 ": ");
-
-        return QTextDocumentFragment::fromHtml(
-                 mtx::accessors::formattedBodyWithFallback(notification.event)
-                   .replace(QRegularExpression("<mx-reply>.+</mx-reply>"), ""))
-          .toPlainText()
-          .prepend(messageLeadIn);
+        const auto template_ = getMessageTemplate(notification);
+        if (std::holds_alternative<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
+              notification.event)) {
+                return template_;
+        }
+
+        return template_.arg(utils::stripReplyFallbacks(notification.event, {}, {}).quoted_body);
 }