summary refs log tree commit diff
path: root/src/notifications
diff options
context:
space:
mode:
authorLoren Burkholder <computersemiexpert@outlook.com>2021-02-13 18:59:17 -0500
committerNicolas Werner <nicolas.werner@hotmail.de>2021-03-17 19:17:13 +0100
commit3dcbac8875c000127f76318b53f0170456b01f2d (patch)
treef2d89f0b0b6f959266036c4d9672e58f4faafd1f /src/notifications
parentParse markdown overrides during replies (diff)
downloadnheko-3dcbac8875c000127f76318b53f0170456b01f2d.tar.xz
Only pass formatted text if it is supported (Linux)
Diffstat (limited to 'src/notifications')
-rw-r--r--src/notifications/ManagerLinux.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp

index 70f131c2..44dbb196 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp
@@ -7,6 +7,7 @@ #include <QDBusPendingReply> #include <QDebug> #include <QImage> +#include <QTextDocumentFragment> #include "Cache.h" #include "EventAccessors.h" @@ -59,7 +60,14 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif const auto sender = cache::displayName( room_id, QString::fromStdString(mtx::accessors::sender(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; hints["image-data"] = icon; @@ -86,9 +94,6 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif argumentList << hints; // hints argumentList << (int)-1; // timeout in ms - static QDBusInterface notifyApp("org.freedesktop.Notifications", - "/org/freedesktop/Notifications", - "org.freedesktop.Notifications"); QDBusPendingCall call = notifyApp.asyncCallWithArgumentList("Notify", argumentList); auto watcher = new QDBusPendingCallWatcher{call, this}; connect(