diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-09-21 08:21:10 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-09-21 08:27:05 +0900 |
commit | e0e115faeb49297437d4efc231e4d57e8275ec2a (patch) | |
tree | 247194ced901196739a92c79373c47d64b4bd465 /events | |
parent | ac5ae85ed43d1f92cfc99bf1ea687d33f56ccd13 (diff) | |
download | libquotient-e0e115faeb49297437d4efc231e4d57e8275ec2a.tar.gz libquotient-e0e115faeb49297437d4efc231e4d57e8275ec2a.zip |
Push sender from RoomTopicEvent to Event
Because it's supposed to exist in (at least) all events from /sync.
Diffstat (limited to 'events')
-rw-r--r-- | events/event.cpp | 12 | ||||
-rw-r--r-- | events/event.h | 1 | ||||
-rw-r--r-- | events/roomtopicevent.cpp | 7 | ||||
-rw-r--r-- | events/roomtopicevent.h | 1 |
4 files changed, 9 insertions, 12 deletions
diff --git a/events/event.cpp b/events/event.cpp index 55114e6b..43604b23 100644 --- a/events/event.cpp +++ b/events/event.cpp @@ -43,6 +43,7 @@ class Event::Private QString id; QDateTime timestamp; QString roomId; + QString senderId; QString originalJson; }; @@ -77,6 +78,11 @@ QString Event::roomId() const return d->roomId; } +QString Event::senderId() const +{ + return d->senderId; +} + QString Event::originalJson() const { return d->originalJson; @@ -131,10 +137,8 @@ bool Event::parseJson(const QJsonObject& obj) qDebug() << formatJson << obj; } } - if( obj.contains("room_id") ) - { - d->roomId = obj.value("room_id").toString(); - } + d->roomId = obj.value("room_id").toString(); + d->senderId = obj.value("sender").toString(); return correct; } diff --git a/events/event.h b/events/event.h index a66f5e68..bb80cde8 100644 --- a/events/event.h +++ b/events/event.h @@ -47,6 +47,7 @@ namespace QMatrixClient QString id() const; QDateTime timestamp() const; QString roomId() const; + QString senderId() const; // only for debug purposes! QString originalJson() const; diff --git a/events/roomtopicevent.cpp b/events/roomtopicevent.cpp index 7ccfc73c..2e186c4b 100644 --- a/events/roomtopicevent.cpp +++ b/events/roomtopicevent.cpp @@ -24,7 +24,6 @@ class RoomTopicEvent::Private { public: QString topic; - QString senderId; }; RoomTopicEvent::RoomTopicEvent() @@ -38,11 +37,6 @@ RoomTopicEvent::~RoomTopicEvent() delete d; } -QString RoomTopicEvent::senderId() const -{ - return d->senderId; -} - QString RoomTopicEvent::topic() const { return d->topic; @@ -53,6 +47,5 @@ RoomTopicEvent* RoomTopicEvent::fromJson(const QJsonObject& obj) auto e = new RoomTopicEvent(); e->parseJson(obj); e->d->topic = obj.value("content").toObject().value("topic").toString(); - e->d->senderId = obj["sender"].toString(); return e; } diff --git a/events/roomtopicevent.h b/events/roomtopicevent.h index 17b10870..f4d87eef 100644 --- a/events/roomtopicevent.h +++ b/events/roomtopicevent.h @@ -31,7 +31,6 @@ namespace QMatrixClient RoomTopicEvent(); virtual ~RoomTopicEvent(); - QString senderId() const; QString topic() const; static RoomTopicEvent* fromJson(const QJsonObject& obj); |