mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Get event text in event parser function
This commit is contained in:
parent
b57b76d948
commit
df998ef671
5 changed files with 15 additions and 9 deletions
|
@ -27,7 +27,7 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
|
|||
((mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Emote)
|
||||
? "* " + sender + " "
|
||||
: sender + reply + ": ") +
|
||||
formatNotification(mtx::accessors::formattedBodyWithFallback(notification.event));
|
||||
formatNotification(notification.event);
|
||||
|
||||
systemPostNotification(room_id, event_id, room_name, sender, text, icon);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
const QString &text,
|
||||
const QImage &icon);
|
||||
|
||||
QString formatNotification(const QString &text);
|
||||
QString formatNotification(const mtx::events::collections::TimelineEvents &e);
|
||||
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_HAIKU)
|
||||
public:
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <functional>
|
||||
|
||||
#include "EventAccessors.h"
|
||||
#include "Utils.h"
|
||||
|
||||
NotificationsManager::NotificationsManager(QObject *parent)
|
||||
|
@ -161,7 +162,7 @@ NotificationsManager::notificationClosed(uint id, uint reason)
|
|||
* specified at https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/Markup/
|
||||
*/
|
||||
QString
|
||||
NotificationsManager::formatNotification(const QString &text)
|
||||
NotificationsManager::formatNotification(const mtx::events::collections::TimelineEvents &e)
|
||||
{
|
||||
static const auto hasMarkup = std::invoke([this]() -> bool {
|
||||
for (auto x : dbus.call("GetCapabilities").arguments())
|
||||
|
@ -169,14 +170,16 @@ NotificationsManager::formatNotification(const QString &text)
|
|||
return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
if (hasMarkup)
|
||||
return QString(text)
|
||||
return mtx::accessors::formattedBodyWithFallback(e)
|
||||
.replace("<em>", "<i>")
|
||||
.replace("</em>", "</i>")
|
||||
.replace("<strong>", "<b>")
|
||||
.replace("</strong>", "</b>");
|
||||
|
||||
return QTextDocumentFragment::fromHtml(text).toPlainText();
|
||||
return QTextDocumentFragment::fromHtml(mtx::accessors::formattedBodyWithFallback(e))
|
||||
.toPlainText();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
#include <QTextDocumentFragment>
|
||||
|
||||
#include "EventAccessors.h"
|
||||
#include "Utils.h"
|
||||
|
||||
QString
|
||||
NotificationsManager::formatNotification(const QString &text)
|
||||
NotificationsManager::formatNotification(const mtx::events::collections::TimelineEvents &e)
|
||||
{
|
||||
return QTextDocumentFragment::fromHtml(text).toPlainText();
|
||||
return QTextDocumentFragment::fromHtml(mtx::accessors::formattedBodyWithFallback(e)).toPlainText();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <QTextDocumentFragment>
|
||||
|
||||
#include "EventAccessors.h"
|
||||
#include "Utils.h"
|
||||
|
||||
using namespace WinToastLib;
|
||||
|
@ -77,7 +78,8 @@ NotificationsManager::removeNotification(const QString &, const QString &)
|
|||
{}
|
||||
|
||||
QString
|
||||
NotificationsManager::formatNotification(const QString &text)
|
||||
NotificationsManager::formatNotification(const mtx::events::collections::TimelineEvents &e)
|
||||
{
|
||||
return QTextDocumentFragment::fromHtml(text).toPlainText();
|
||||
return QTextDocumentFragment::fromHtml(mtx::accessors::formattedBodyWithFallback(e)).toPlainText();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue