Move notification parsing into postNotification
This commit is contained in:
parent
9f9c499cb2
commit
567b2d05ef
5 changed files with 59 additions and 62 deletions
|
|
@ -1,6 +1,12 @@
|
|||
#include "notifications/Manager.h"
|
||||
#include "wintoastlib.h"
|
||||
|
||||
#include "Cache.h"
|
||||
#include "EventAccessors.h"
|
||||
#include "MatrixClient.h"
|
||||
#include "Utils.h"
|
||||
#include <mtx/responses.hpp>
|
||||
|
||||
using namespace WinToastLib;
|
||||
|
||||
class CustomHandler : public IWinToastHandler
|
||||
|
|
@ -32,18 +38,18 @@ NotificationsManager::NotificationsManager(QObject *parent)
|
|||
{}
|
||||
|
||||
void
|
||||
NotificationsManager::postNotification(const QString &room_id,
|
||||
const QString &event_id,
|
||||
const QString &room_name,
|
||||
const QString &sender,
|
||||
const QString &text,
|
||||
const QImage &icon,
|
||||
const bool &isEmoteMessage)
|
||||
NotificationsManager::postNotification(const mtx::responses::Notification ¬ification,
|
||||
const QImage &icon)
|
||||
{
|
||||
Q_UNUSED(room_id)
|
||||
Q_UNUSED(event_id)
|
||||
Q_UNUSED(icon)
|
||||
|
||||
const auto room_name =
|
||||
QString::fromStdString(cache::singleRoomInfo(notification.room_id).name);
|
||||
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);
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
|
|
@ -54,7 +60,7 @@ NotificationsManager::postNotification(const QString &room_id,
|
|||
else
|
||||
templ.setTextField(QString("%1").arg(sender).toStdWString(),
|
||||
WinToastTemplate::FirstLine);
|
||||
if (isEmoteMessage)
|
||||
if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Emote)
|
||||
templ.setTextField(
|
||||
QString("* ").append(sender).append(" ").append(text).toStdWString(),
|
||||
WinToastTemplate::SecondLine);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue