mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 12:38:48 +03:00
Don't send useless formatted_bodies
This commit is contained in:
parent
9c368fa7f4
commit
e81a4e8f9a
2 changed files with 10 additions and 1 deletions
|
@ -397,6 +397,10 @@ utils::markdownToHtml(const QString &text)
|
||||||
|
|
||||||
auto result = linkifyMessage(escapeBlacklistedHtml(QString::fromStdString(html))).trimmed();
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,8 +188,13 @@ TimelineViewManager::queueTextMessage(const QString &msg, const std::optional<Re
|
||||||
text.body = msg.trimmed().toStdString();
|
text.body = msg.trimmed().toStdString();
|
||||||
|
|
||||||
if (settings->isMarkdownEnabled()) {
|
if (settings->isMarkdownEnabled()) {
|
||||||
text.format = "org.matrix.custom.html";
|
|
||||||
text.formatted_body = utils::markdownToHtml(msg).toStdString();
|
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) {
|
if (related) {
|
||||||
|
|
Loading…
Reference in a new issue