diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-11-01 17:40:30 +0300 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-11-01 17:41:59 +0300 |
commit | 2931b4d13e1883150b92f80f08aa51d86ac2445f (patch) | |
tree | 0123b25a3eea89e6475d4b10c39564e3a4087014 /events | |
parent | f591e02176f494c06c7288f975e8571dda2bc6ad (diff) | |
download | libquotient-2931b4d13e1883150b92f80f08aa51d86ac2445f.tar.gz libquotient-2931b4d13e1883150b92f80f08aa51d86ac2445f.zip |
ReceiptEvent: Use fromJson<>() from converters.h; add TypeId
Event::toTimestamp() duplicates fromJson<>() code, so it should go.
Diffstat (limited to 'events')
-rw-r--r-- | events/receiptevent.cpp | 6 | ||||
-rw-r--r-- | events/receiptevent.h | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/events/receiptevent.cpp b/events/receiptevent.cpp index 646bb989..b36ddb23 100644 --- a/events/receiptevent.cpp +++ b/events/receiptevent.cpp @@ -35,10 +35,9 @@ Example of a Receipt Event: #include "receiptevent.h" +#include "converters.h" #include "logging.h" -#include <QtCore/QJsonArray> - using namespace QMatrixClient; ReceiptEvent::ReceiptEvent(const QJsonObject& obj) @@ -62,7 +61,8 @@ ReceiptEvent::ReceiptEvent(const QJsonObject& obj) for( auto userIt = reads.begin(); userIt != reads.end(); ++userIt ) { const QJsonObject user = userIt.value().toObject(); - receipts.push_back({userIt.key(), toTimestamp(user["ts"])}); + receipts.push_back({userIt.key(), + QMatrixClient::fromJson<QDateTime>(user["ts"])}); } _eventsWithReceipts.push_back({eventIt.key(), receipts}); } diff --git a/events/receiptevent.h b/events/receiptevent.h index cbe36b10..15fdf946 100644 --- a/events/receiptevent.h +++ b/events/receiptevent.h @@ -43,6 +43,8 @@ namespace QMatrixClient { return _eventsWithReceipts; } bool unreadMessages() const { return _unreadMessages; } + static constexpr const char* const TypeId = "m.receipt"; + private: EventsWithReceipts _eventsWithReceipts; bool _unreadMessages; // Spec extension for caching purposes |