aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--events/event.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/events/event.cpp b/events/event.cpp
index 43604b23..11983f53 100644
--- a/events/event.cpp
+++ b/events/event.cpp
@@ -114,31 +114,31 @@ Event* Event::fromJson(const QJsonObject& obj)
bool Event::parseJson(const QJsonObject& obj)
{
d->originalJson = QString::fromUtf8(QJsonDocument(obj).toJson());
+ d->id = obj.value("event_id").toString();
+ d->roomId = obj.value("room_id").toString();
+ d->senderId = obj.value("sender").toString();
bool correct = (d->type != EventType::Unknown);
- if ( d->type != EventType::Unknown &&
- d->type != EventType::Typing &&
+ if ( d->type != EventType::Typing &&
d->type != EventType::Receipt )
{
- if( obj.contains("event_id") )
+ if (d->id.isEmpty())
{
- d->id = obj.value("event_id").toString();
- } else {
correct = false;
- qDebug() << "Event: can't find event_id";
+ qDebug() << "Event: can't find event_id; event dump follows";
qDebug() << formatJson << obj;
}
if( obj.contains("origin_server_ts") )
{
- d->timestamp = QDateTime::fromMSecsSinceEpoch(
+ d->timestamp = QDateTime::fromMSecsSinceEpoch(
static_cast<qint64>(obj.value("origin_server_ts").toDouble()), Qt::UTC );
- } else {
+ }
+ else if (d->type != EventType::Unknown)
+ {
correct = false;
- qDebug() << "Event: can't find ts";
+ qDebug() << "Event: can't find ts; event dump follows";
qDebug() << formatJson << obj;
}
}
- d->roomId = obj.value("room_id").toString();
- d->senderId = obj.value("sender").toString();
return correct;
}