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

Add regex to remove replies in notifications

parent c693d545
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@
#include <QDBusPendingReply>
#include <QDebug>
#include <QImage>
#include <QRegularExpression>
#include <QTextDocumentFragment>
#include <functional>
......@@ -176,9 +177,12 @@ NotificationsManager::formatNotification(const mtx::events::collections::Timelin
.replace("<em>", "<i>")
.replace("</em>", "</i>")
.replace("<strong>", "<b>")
.replace("</strong>", "</b>");
.replace("</strong>", "</b>")
.replace(QRegularExpression("(<mx-reply>.+\\<\\/mx-reply\\>)"), "");
return QTextDocumentFragment::fromHtml(mtx::accessors::formattedBodyWithFallback(e))
return QTextDocumentFragment::fromHtml(
mtx::accessors::formattedBodyWithFallback(e).replace(
QRegularExpression("(<mx-reply>.+\\<\\/mx-reply\\>)"), ""))
.toPlainText();
}
......
#include "Manager.h"
#include <QRegularExpression>
#include <QTextDocumentFragment>
#include "EventAccessors.h"
......@@ -8,5 +9,8 @@
QString
NotificationsManager::formatNotification(const mtx::events::collections::TimelineEvents &e)
{
return QTextDocumentFragment::fromHtml(mtx::accessors::formattedBodyWithFallback(e)).toPlainText();
return QTextDocumentFragment::fromHtml(
mtx::accessors::formattedBodyWithFallback(e).replace(
QRegularExpression("(<mx-reply>.+\\<\\/mx-reply\\>)"), ""))
.toPlainText();
}
......@@ -5,6 +5,7 @@
#include "notifications/Manager.h"
#include "wintoastlib.h"
#include <QRegularExpression>
#include <QTextDocumentFragment>
#include "EventAccessors.h"
......@@ -80,6 +81,8 @@ NotificationsManager::removeNotification(const QString &, const QString &)
QString
NotificationsManager::formatNotification(const mtx::events::collections::TimelineEvents &e)
{
return QTextDocumentFragment::fromHtml(mtx::accessors::formattedBodyWithFallback(e)).toPlainText();
return QTextDocumentFragment::fromHtml(
mtx::accessors::formattedBodyWithFallback(e).replace(
QRegularExpression("(<mx-reply>.+\\<\\/mx-reply\\>)"), ""))
.toPlainText();
}
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