diff options
author | Loren Burkholder <computersemiexpert@outlook.com> | 2021-02-15 18:36:10 -0500 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-03-17 19:17:13 +0100 |
commit | 648844089c1786f1439ea026d1f3f5d0b757a414 (patch) | |
tree | f0d0ea22de30ba1dccc266bbda3e4c7335ed1fba /src/notifications/ManagerMac.mm | |
parent | make lint (diff) | |
download | nheko-648844089c1786f1439ea026d1f3f5d0b757a414.tar.xz |
Move data parsing into a dedicated function
Actually posting the notification is now the responsibility of a private function
Diffstat (limited to 'src/notifications/ManagerMac.mm')
-rw-r--r-- | src/notifications/ManagerMac.mm | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/notifications/ManagerMac.mm b/src/notifications/ManagerMac.mm index af0b5a02..3372c5af 100644 --- a/src/notifications/ManagerMac.mm +++ b/src/notifications/ManagerMac.mm @@ -3,13 +3,6 @@ #include <Foundation/Foundation.h> #include <QtMac> -#include "Cache.h" -#include "EventAccessors.h" -#include "MatrixClient.h" -#include "Utils.h" -#include <mtx/responses/notifications.hpp> -#include <cmark.h> - @interface NSUserNotification (CFIPrivate) - (void)set_identityImage:(NSImage *)image; @end @@ -20,23 +13,22 @@ NotificationsManager::NotificationsManager(QObject *parent): QObject(parent) } void -NotificationsManager::postNotification(const mtx::responses::Notification ¬ification, - const QImage &icon) +NotificationsManager::systemPostNotification(const QString &room_id, + const QString &event_id, + const QString &roomName, + const QString &sender, + const QString &text, + const QImage &icon) { - 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); - const auto formattedText = cmark_markdown_to_html(text.toStdString().c_str(), text.length(), CMARK_OPT_UNSAFE); + Q_UNUSED(room_id) + Q_UNUSED(event_id) + Q_UNUSED(icon) NSUserNotification * notif = [[NSUserNotification alloc] init]; - notif.title = QString::fromStdString(cache::singleRoomInfo(notification.room_id).name).toNSString(); + notif.title = roomName.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(formattedText).toNSString(); - else - notif.informativeText = formattedText.toNSString(); + notif.informativeText = text.toNSString(); notif.soundName = NSUserNotificationDefaultSoundName; [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notif]; |