diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-01-06 17:45:34 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-01-06 17:45:34 +0900 |
commit | c83a73b17eaef465150458282e63a478ba238f26 (patch) | |
tree | d6c2416fa765d2fb00924da9e5086a5a743294b2 /lib/events/stateevent.cpp | |
parent | a23fa6df08008f4a3f7437efa8afe839a102dc8e (diff) | |
download | libquotient-c83a73b17eaef465150458282e63a478ba238f26.tar.gz libquotient-c83a73b17eaef465150458282e63a478ba238f26.zip |
Create StateEventBase events if state_key is there
This makes unknown state events to still be treated as state events.
Diffstat (limited to 'lib/events/stateevent.cpp')
-rw-r--r-- | lib/events/stateevent.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/events/stateevent.cpp b/lib/events/stateevent.cpp index fd8079be..c4151676 100644 --- a/lib/events/stateevent.cpp +++ b/lib/events/stateevent.cpp @@ -20,8 +20,19 @@ using namespace QMatrixClient; +// Aside from the normal factory to instantiate StateEventBase inheritors +// StateEventBase itself can be instantiated if there's a state_key JSON key +// but the event type is unknown. [[gnu::unused]] static auto stateEventTypeInitialised = - RoomEvent::factory_t::chainFactory<StateEventBase>(); + RoomEvent::factory_t::addMethod( + [] (const QJsonObject& json, const QString& matrixType) + { + if (auto e = StateEventBase::factory_t::make(json, matrixType)) + return e; + return json.contains("state_key") + ? makeEvent<StateEventBase>(unknownEventTypeId(), json) + : nullptr; + }); bool StateEventBase::repeatsState() const { |