summary refs log tree commit diff
path: root/src/notifications/ManagerMac.mm
diff options
context:
space:
mode:
authorLoren Burkholder <computersemiexpert@outlook.com>2021-02-13 12:10:49 -0500
committerLoren Burkholder <computersemiexpert@outlook.com>2021-02-13 13:40:26 -0500
commit567b2d05effd32c8804e3039250e3b44d4e7c91e (patch)
tree1240f28f762d40b5b22ec3090dab6003f25df4b1 /src/notifications/ManagerMac.mm
parentFix typo (diff)
downloadnheko-567b2d05effd32c8804e3039250e3b44d4e7c91e.tar.xz
Move notification parsing into postNotification
Diffstat (limited to 'src/notifications/ManagerMac.mm')
-rw-r--r--src/notifications/ManagerMac.mm29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/notifications/ManagerMac.mm b/src/notifications/ManagerMac.mm

index e21cc904..e50bee89 100644 --- a/src/notifications/ManagerMac.mm +++ b/src/notifications/ManagerMac.mm
@@ -3,6 +3,12 @@ #include <Foundation/Foundation.h> #include <QtMac> +#include "Cache.h" +#include "EventAccessors.h" +#include "MatrixClient.h" +#include "Utils.h" +#include <mtx/responses.hpp> + @interface NSUserNotification (CFIPrivate) - (void)set_identityImage:(NSImage *)image; @end @@ -13,25 +19,20 @@ NotificationsManager::NotificationsManager(QObject *parent): QObject(parent) } void -NotificationsManager::postNotification( - const QString &roomId, - const QString &eventId, - const QString &roomName, - const QString &senderName, - const QString &text, - const QImage &icon, - const bool &isEmoteMessage) +NotificationsManager::postNotification(const mtx::responses::Notification &notification, + const QImage &icon) { - Q_UNUSED(roomId); - Q_UNUSED(eventId); Q_UNUSED(icon); + const auto sender = cache::displayName(QString::fromStdString(notification.room_id), QString::fromStdString(mtx::accessors::sender(notification.event))); + const auto text = utils::event_body(notification.event); + NSUserNotification * notif = [[NSUserNotification alloc] init]; - notif.title = roomName.toNSString(); - notif.subtitle = QString("%1 sent a message").arg(senderName).toNSString(); - if (isEmoteMessage) - notif.informativeText = QString("* ").append(senderName).append(" ").append(text).toNSString(); + notif.title = QString::fromStdString(cache::singleRoomInfo(notification.room_id).name).toNSString(); + notif.subtitle = QString("%1 sent a message").arg(sender).toNSString(); + if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Emote) + notif.informativeText = QString("* ").append(sender).append(" ").append(text).toNSString(); else notif.informativeText = text.toNSString(); notif.soundName = NSUserNotificationDefaultSoundName;