From 581a6976eeb7c35930cb19e89eae0fd3bf11a785 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 24 Aug 2016 14:29:54 +0900 Subject: Move plain body from Base (former MessageEventContent) inside RoomMessageEvent According to the spec, this key has the same status as msgtype: both should exist in any message. Besides, it's always supposed to be a plain text so there's no polymorphism allowed here. --- events/roommessageevent.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'events/roommessageevent.cpp') diff --git a/events/roommessageevent.cpp b/events/roommessageevent.cpp index 03e84444..a111ef12 100644 --- a/events/roommessageevent.cpp +++ b/events/roommessageevent.cpp @@ -31,6 +31,7 @@ class RoomMessageEvent::Private QString userId; MessageEventType msgtype; + QString plainBody; QDateTime hsob_ts; MessageEventContent::Base* content; }; @@ -57,9 +58,14 @@ MessageEventType RoomMessageEvent::msgtype() const return d->msgtype; } +QString RoomMessageEvent::plainBody() const +{ + return d->plainBody; +} + QString RoomMessageEvent::body() const { - return d->content->body; + return plainBody(); } QDateTime RoomMessageEvent::hsob_ts() const @@ -179,7 +185,7 @@ RoomMessageEvent* RoomMessageEvent::fromJson(const QJsonObject& obj) if( content.contains("body") ) { - e->d->content->body = content.value("body").toString(); + e->d->plainBody = content.value("body").toString(); } else { qDebug() << "RoomMessageEvent: body not found"; } -- cgit v1.2.3