Skip to content
Snippets Groups Projects
Verified Commit 3dcbac88 authored by Loren Burkholder's avatar Loren Burkholder Committed by Nicolas Werner
Browse files

Only pass formatted text if it is supported (Linux)

parent c74e68c9
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <QDBusPendingReply> #include <QDBusPendingReply>
#include <QDebug> #include <QDebug>
#include <QImage> #include <QImage>
#include <QTextDocumentFragment>
#include "Cache.h" #include "Cache.h"
#include "EventAccessors.h" #include "EventAccessors.h"
...@@ -59,7 +60,14 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif ...@@ -59,7 +60,14 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif
const auto sender = cache::displayName( const auto sender = cache::displayName(
room_id, QString::fromStdString(mtx::accessors::sender(notification.event))); room_id, QString::fromStdString(mtx::accessors::sender(notification.event)));
const auto text = utils::event_body(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); auto formattedText = utils::markdownToHtml(text);
static QDBusInterface notifyApp("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications");
auto capabilites = notifyApp.call("GetCapabilites");
if (!capabilites.arguments().contains("body-markup"))
formattedText = QTextDocumentFragment::fromHtml(formattedText).toPlainText();
QVariantMap hints; QVariantMap hints;
hints["image-data"] = icon; hints["image-data"] = icon;
...@@ -86,9 +94,6 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif ...@@ -86,9 +94,6 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif
argumentList << hints; // hints argumentList << hints; // hints
argumentList << (int)-1; // timeout in ms argumentList << (int)-1; // timeout in ms
static QDBusInterface notifyApp("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications");
QDBusPendingCall call = notifyApp.asyncCallWithArgumentList("Notify", argumentList); QDBusPendingCall call = notifyApp.asyncCallWithArgumentList("Notify", argumentList);
auto watcher = new QDBusPendingCallWatcher{call, this}; auto watcher = new QDBusPendingCallWatcher{call, this};
connect( connect(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment