1 files changed, 24 insertions, 7 deletions
diff --git a/src/notifications/Manager.cpp b/src/notifications/Manager.cpp
index 895beaf7..d15eea51 100644
--- a/src/notifications/Manager.cpp
+++ b/src/notifications/Manager.cpp
@@ -22,14 +22,31 @@ NotificationsManager::getMessageTemplate(const mtx::responses::Notification ¬
return tr("%1 sent an encrypted message").arg(sender);
}
- if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Emote) {
- return QStringLiteral("* %1 %2").arg(sender);
- } else if (utils::isReply(notification.event)) {
- return tr("%1 replied: %2",
- "Format a reply in a notification. %1 is the sender, %2 the message")
- .arg(sender);
+ bool containsSpoiler =
+ mtx::accessors::formatted_body(notification.event).find("<span data-mx-spoiler") !=
+ std::string::npos;
+
+ if (containsSpoiler) {
+ // Because we skip the %2 here, this might cause a warning in some cases.
+ if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Emote) {
+ return QStringLiteral("* %1 spoils something.").arg(sender);
+ } else if (utils::isReply(notification.event)) {
+ return tr("%1 replied with a spoiler.",
+ "Format a reply in a notification. %1 is the sender.")
+ .arg(sender);
+ } else {
+ return QStringLiteral("%1 sent a spoiler.").arg(sender);
+ }
} else {
- return QStringLiteral("%1: %2").arg(sender);
+ if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Emote) {
+ return QStringLiteral("* %1 %2").arg(sender);
+ } else if (utils::isReply(notification.event)) {
+ return tr("%1 replied: %2",
+ "Format a reply in a notification. %1 is the sender, %2 the message")
+ .arg(sender);
+ } else {
+ return QStringLiteral("%1: %2").arg(sender);
+ }
}
}
|