diff options
Diffstat (limited to 'events')
-rw-r--r-- | events/event.cpp | 27 | ||||
-rw-r--r-- | events/event.h | 14 | ||||
-rw-r--r-- | events/roommemberevent.h | 7 |
3 files changed, 33 insertions, 15 deletions
diff --git a/events/event.cpp b/events/event.cpp index c7345a13..7bc25a07 100644 --- a/events/event.cpp +++ b/events/event.cpp @@ -88,11 +88,12 @@ EventPtr _impl::doMakeEvent<Event>(const QJsonObject& obj) RoomEvent::RoomEvent(Event::Type type) : Event(type) { } RoomEvent::RoomEvent(Type type, const QJsonObject& rep) - : Event(type, rep), _id(rep["event_id"].toString()) - , _roomId(rep["room_id"].toString()) - , _senderId(rep["sender"].toString()) - , _serverTimestamp( - QMatrixClient::fromJson<QDateTime>(rep["origin_server_ts"])) + : Event(type, rep) + , _id(rep["event_id"].toString()) +// , _roomId(rep["room_id"].toString()) +// , _senderId(rep["sender"].toString()) +// , _serverTimestamp( +// QMatrixClient::fromJson<QDateTime>(rep["origin_server_ts"])) { // if (_id.isEmpty()) // { @@ -124,6 +125,22 @@ RoomEvent::RoomEvent(Type type, const QJsonObject& rep) RoomEvent::~RoomEvent() = default; // Let the smart pointer do its job +QDateTime RoomEvent::timestamp() const +{ + return QMatrixClient::fromJson<QDateTime>( + originalJsonObject().value("origin_server_ts")); +} + +QString RoomEvent::roomId() const +{ + return originalJsonObject().value("room_id").toString(); +} + +QString RoomEvent::senderId() const +{ + return originalJsonObject().value("sender_id").toString(); +} + QString RoomEvent::redactionReason() const { return isRedacted() ? _redactedBecause->reason() : QString{}; diff --git a/events/event.h b/events/event.h index b5a4d94e..968bc1ad 100644 --- a/events/event.h +++ b/events/event.h @@ -167,10 +167,10 @@ namespace QMatrixClient RoomEvent(Type type, const QJsonObject& rep); ~RoomEvent(); - const QString& id() const { return _id; } - const QDateTime& timestamp() const { return _serverTimestamp; } - const QString& roomId() const { return _roomId; } - const QString& senderId() const { return _senderId; } + QString id() const { return _id; } + QDateTime timestamp() const; + QString roomId() const; + QString senderId() const; bool isRedacted() const { return bool(_redactedBecause); } const RedactionEvent* redactedBecause() const { @@ -202,9 +202,9 @@ namespace QMatrixClient private: QString _id; - QString _roomId; - QString _senderId; - QDateTime _serverTimestamp; +// QString _roomId; +// QString _senderId; +// QDateTime _serverTimestamp; event_ptr_tt<RedactionEvent> _redactedBecause; QString _txnId; }; diff --git a/events/roommemberevent.h b/events/roommemberevent.h index d0c63f15..224f29c2 100644 --- a/events/roommemberevent.h +++ b/events/roommemberevent.h @@ -53,16 +53,17 @@ namespace QMatrixClient explicit RoomMemberEvent(const QJsonObject& obj) : StateEvent(Type::RoomMember, obj) - , _userId(obj["state_key"].toString()) +// , _userId(obj["state_key"].toString()) { } MembershipType membership() const { return content().membership; } - QString userId() const { return _userId; } + QString userId() const + { return originalJsonObject().value("state_key").toString(); } QString displayName() const { return content().displayName; } QUrl avatarUrl() const { return content().avatarUrl; } private: - QString _userId; +// QString _userId; REGISTER_ENUM(MembershipType) }; } // namespace QMatrixClient |