summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-01-27 17:25:09 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-01-27 17:25:09 +0100
commite81a4e8f9abb7f2dbdc419929bcaf6a3d4065bea (patch)
tree4d96d5194f7e6317c09eef9ca587ee62b8edc203 /src
parentFix reply rendering without markdown in riot (diff)
downloadnheko-e81a4e8f9abb7f2dbdc419929bcaf6a3d4065bea.tar.xz
Don't send useless formatted_bodies
Diffstat (limited to 'src')
-rw-r--r--src/Utils.cpp4
-rw-r--r--src/timeline/TimelineViewManager.cpp7
2 files changed, 10 insertions, 1 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp

index 5a67ef62..76ffed31 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp
@@ -397,6 +397,10 @@ utils::markdownToHtml(const QString &text) auto result = linkifyMessage(escapeBlacklistedHtml(QString::fromStdString(html))).trimmed(); + if (result.count("<p>") == 1 && result.startsWith("<p>") && result.endsWith("</p>")) { + result = result.mid(3, result.size() - 3 - 4); + } + return result; } diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index 9008d9d2..a1f23cf5 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp
@@ -188,8 +188,13 @@ TimelineViewManager::queueTextMessage(const QString &msg, const std::optional<Re text.body = msg.trimmed().toStdString(); if (settings->isMarkdownEnabled()) { - text.format = "org.matrix.custom.html"; text.formatted_body = utils::markdownToHtml(msg).toStdString(); + + // Don't send formatted_body, when we don't need to + if (text.formatted_body == text.body) + text.formatted_body = ""; + else + text.format = "org.matrix.custom.html"; } if (related) {