aboutsummaryrefslogtreecommitdiff
path: root/lib/events/roommessageevent.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-10 20:18:21 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-10 20:18:21 +0900
commite66cae5fd3e74c5839804e560332e5690709931a (patch)
treeafdef32c421200cd669991d1db05167b9e8d7b36 /lib/events/roommessageevent.cpp
parenta0f49a396c9bd2a9f65df2682f8a6618e79c5dc7 (diff)
downloadlibquotient-e66cae5fd3e74c5839804e560332e5690709931a.tar.gz
libquotient-e66cae5fd3e74c5839804e560332e5690709931a.zip
Room::postHtmlMessage() - a facility method to send HTML messages
Diffstat (limited to 'lib/events/roommessageevent.cpp')
-rw-r--r--lib/events/roommessageevent.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/events/roommessageevent.cpp b/lib/events/roommessageevent.cpp
index e07054a4..1c5cf058 100644
--- a/lib/events/roommessageevent.cpp
+++ b/lib/events/roommessageevent.cpp
@@ -164,7 +164,10 @@ bool RoomMessageEvent::hasThumbnail() const
TextContent::TextContent(const QString& text, const QString& contentType)
: mimeType(QMimeDatabase().mimeTypeForName(contentType)), body(text)
-{ }
+{
+ if (contentType == "org.matrix.custom.html")
+ mimeType = QMimeDatabase().mimeTypeForName("text/html");
+}
TextContent::TextContent(const QJsonObject& json)
{
@@ -189,9 +192,12 @@ TextContent::TextContent(const QJsonObject& json)
void TextContent::fillJson(QJsonObject* json) const
{
Q_ASSERT(json);
- json->insert(QStringLiteral("format"),
- QStringLiteral("org.matrix.custom.html"));
- json->insert(QStringLiteral("formatted_body"), body);
+ if (mimeType.inherits("text/html"))
+ {
+ json->insert(QStringLiteral("format"),
+ QStringLiteral("org.matrix.custom.html"));
+ json->insert(QStringLiteral("formatted_body"), body);
+ }
}
LocationContent::LocationContent(const QString& geoUri, const ImageInfo& thumbnail)