aboutsummaryrefslogtreecommitdiff
path: root/lib/events/event.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-05-05 19:36:15 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-05-05 19:36:15 +0900
commita8d2a73c771f188fc0fdc6351b4923af788317d5 (patch)
treeb2795b93149f7c0ae3cd5005331b650a8eb6fd1e /lib/events/event.cpp
parentda16225dfbec9b155c2c299757203f7676ac6ccf (diff)
parenta63838235134b066c092ad98e1f18ff7991c91c1 (diff)
downloadlibquotient-a8d2a73c771f188fc0fdc6351b4923af788317d5.tar.gz
libquotient-a8d2a73c771f188fc0fdc6351b4923af788317d5.zip
Merge branch 'kitsune-gtad'
Diffstat (limited to 'lib/events/event.cpp')
-rw-r--r--lib/events/event.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/events/event.cpp b/lib/events/event.cpp
index 1d5f1b0d..576e9426 100644
--- a/lib/events/event.cpp
+++ b/lib/events/event.cpp
@@ -76,7 +76,7 @@ template <typename BaseEventT, typename EventT, typename... EventTs>
inline event_ptr_tt<BaseEventT> makeIfMatches(const QJsonObject& o,
const QString& selector)
{
- if (selector == EventT::TypeId)
+ if (selector == EventT::typeId())
return _impl::create<EventT>(o);
return makeIfMatches<BaseEventT, EventTs...>(o, selector);
@@ -160,14 +160,13 @@ void RoomEvent::addId(const QString& id)
template <>
RoomEventPtr _impl::doMakeEvent(const QJsonObject& obj)
{
- return RoomEventPtr { makeIfMatches<RoomEvent,
- RoomMessageEvent, RoomNameEvent, RoomAliasesEvent,
- RoomCanonicalAliasEvent, RoomMemberEvent, RoomTopicEvent,
- RoomAvatarEvent, EncryptionEvent, RedactionEvent>
- (obj, obj["type"].toString()) };
-}
+ // Check more specific event types first
+ if (auto e = doMakeEvent<StateEventBase>(obj))
+ return ptrCast<RoomEvent>(move(e));
-StateEventBase::~StateEventBase() = default;
+ return makeIfMatches<RoomEvent,
+ RoomMessageEvent, RedactionEvent>(obj, obj["type"].toString());
+}
bool StateEventBase::repeatsState() const
{
@@ -176,3 +175,13 @@ bool StateEventBase::repeatsState() const
.toObject().value("prev_content");
return contentJson == prevContentJson;
}
+
+template<>
+StateEventPtr _impl::doMakeEvent<StateEventBase>(const QJsonObject& obj)
+{
+ return makeIfMatches<StateEventBase,
+ RoomNameEvent, RoomAliasesEvent,
+ RoomCanonicalAliasEvent, RoomMemberEvent, RoomTopicEvent,
+ RoomAvatarEvent, EncryptionEvent>(obj, obj["type"].toString());
+
+}