aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-12-11 12:26:05 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-12-11 12:26:05 +0900
commit0e67d1e92285e0c03e4e34ad747490ae4dc5482d (patch)
tree7444b86d22118f612f63ea3eee80b2c29ef24587 /lib
parentc6720cc8bb8d45ab4d2b7390f076d50cb59cb8d3 (diff)
downloadlibquotient-0e67d1e92285e0c03e4e34ad747490ae4dc5482d.tar.gz
libquotient-0e67d1e92285e0c03e4e34ad747490ae4dc5482d.zip
RoomMemberEvent: properly integrate with GetMembersByRoomJob
GetMembersByRoomJob was dysfunctional so far, creating "unknown RoomMemberEvents" instead of proper ones. Now that we need it for lazy- loading, it's fixed!
Diffstat (limited to 'lib')
-rw-r--r--lib/events/roommemberevent.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h
index 149d74f8..b8224033 100644
--- a/lib/events/roommemberevent.h
+++ b/lib/events/roommemberevent.h
@@ -60,8 +60,16 @@ namespace QMatrixClient
: StateEvent(typeId(), matrixTypeId(), c)
{ }
- // This is a special constructor enabling RoomMemberEvent to be
- // a base class for more specific member events.
+ /// A special constructor to create unknown RoomMemberEvents
+ /**
+ * This is needed in order to use RoomMemberEvent as a "base event
+ * class" in cases like GetMembersByRoomJob when RoomMemberEvents
+ * (rather than RoomEvents or StateEvents) are resolved from JSON.
+ * For such cases loadEvent<> requires an underlying class to be
+ * constructible with unknownTypeId() instead of its genuine id.
+ * Don't use it directly.
+ * \sa GetMembersByRoomJob, loadEvent, unknownTypeId
+ */
RoomMemberEvent(Type type, const QJsonObject& fullJson)
: StateEvent(type, fullJson)
{ }
@@ -81,6 +89,18 @@ namespace QMatrixClient
private:
REGISTER_ENUM(MembershipType)
};
+
+ template <>
+ class EventFactory<RoomMemberEvent>
+ {
+ public:
+ static event_ptr_tt<RoomMemberEvent> make(const QJsonObject& json,
+ const QString&)
+ {
+ return makeEvent<RoomMemberEvent>(json);
+ }
+ };
+
REGISTER_EVENT_TYPE(RoomMemberEvent)
DEFINE_EVENTTYPE_ALIAS(RoomMember, RoomMemberEvent)
} // namespace QMatrixClient