mirror of https://github.com/Nheko-Reborn/nheko
Actually posting the notification is now the responsibility of a private functionpull/475/head
parent
09303ca49f
commit
648844089c
@ -0,0 +1,27 @@ |
||||
#include "notifications/Manager.h" |
||||
|
||||
#include "Cache.h" |
||||
#include "EventAccessors.h" |
||||
#include "Utils.h" |
||||
#include <mtx/responses/notifications.hpp> |
||||
|
||||
void |
||||
NotificationsManager::postNotification(const mtx::responses::Notification ¬ification, |
||||
const QImage &icon) |
||||
{ |
||||
const auto room_id = QString::fromStdString(notification.room_id); |
||||
const auto event_id = QString::fromStdString(mtx::accessors::event_id(notification.event)); |
||||
const auto room_name = |
||||
QString::fromStdString(cache::singleRoomInfo(notification.room_id).name); |
||||
const auto sender = cache::displayName( |
||||
room_id, QString::fromStdString(mtx::accessors::sender(notification.event))); |
||||
|
||||
QString text; |
||||
if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Emote) |
||||
text = |
||||
"* " + sender + " " + formatNotification(utils::event_body(notification.event)); |
||||
else |
||||
text = sender + ":" + formatNotification(utils::event_body(notification.event)); |
||||
|
||||
systemPostNotification(room_id, event_id, room_name, sender, text, icon); |
||||
} |
@ -0,0 +1,11 @@ |
||||
#include "Manager.h" |
||||
|
||||
#include <QTextDocumentFragment> |
||||
|
||||
#include "Utils.h" |
||||
|
||||
QString |
||||
NotificationsManager::formatNotification(const QString &text) |
||||
{ |
||||
return utils::markdownToHtml(text); |
||||
} |
Loading…
Reference in new issue