summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-03-17 22:13:12 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-03-17 22:13:12 +0100
commit1408b1a97d37a732ec06916489a60cd9e4d9f6dd (patch)
tree2f0bcab4c7a971be7aa438a8ee7167676beb126b
parentFix shadowing (diff)
downloadnheko-1408b1a97d37a732ec06916489a60cd9e4d9f6dd.tar.xz
Make CI happy
-rw-r--r--src/notifications/ManagerMac.cpp4
-rw-r--r--src/notifications/ManagerWin.cpp30
2 files changed, 15 insertions, 19 deletions
diff --git a/src/notifications/ManagerMac.cpp b/src/notifications/ManagerMac.cpp
index be56585c..8e36985c 100644
--- a/src/notifications/ManagerMac.cpp
+++ b/src/notifications/ManagerMac.cpp
@@ -16,8 +16,8 @@
 
 #include <variant>
 
-QString
-NotificationsManager::formatNotification(const mtx::responses::Notification &notification)
+static QString
+formatNotification(const mtx::responses::Notification &notification)
 {
         return utils::stripReplyFallbacks(notification.event, {}, {}).quoted_body;
 }
diff --git a/src/notifications/ManagerWin.cpp b/src/notifications/ManagerWin.cpp
index d37bff67..fe7830a7 100644
--- a/src/notifications/ManagerWin.cpp
+++ b/src/notifications/ManagerWin.cpp
@@ -60,11 +60,23 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif
             &notification.event) != nullptr;
         const auto isReply = utils::isReply(notification.event);
 
+        auto formatNotification = [this, notification, sender] {
+                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);
+        };
+
         const auto line1 =
           (room_name == sender) ? sender : QString("%1 - %2").arg(sender).arg(room_name);
         const auto line2 = (isEncrypted ? (isReply ? tr("%1 replied with an encrypted message")
                                                    : tr("%1 sent an encrypted message"))
-                                        : formatNotification(notification));
+                                        : formatNotification());
 
         auto iconPath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) +
                         room_name + "-room-avatar.png";
@@ -100,19 +112,3 @@ void NotificationsManager::notificationClosed(uint, uint) {}
 void
 NotificationsManager::removeNotification(const QString &, const QString &)
 {}
-
-QString
-NotificationsManager::formatNotification(const mtx::responses::Notification &notification)
-{
-        const auto sender =
-          cache::displayName(QString::fromStdString(notification.room_id),
-                             QString::fromStdString(mtx::accessors::sender(notification.event)));
-
-        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);
-}