Get event text in event parser function

This commit is contained in:
Loren Burkholder 2021-02-20 13:16:43 -05:00 committed by Nicolas Werner
parent b57b76d948
commit df998ef671
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
5 changed files with 15 additions and 9 deletions

View file

@ -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();
}
/**