aboutsummaryrefslogtreecommitdiff
path: root/lib/events/roommemberevent.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/events/roommemberevent.h')
-rw-r--r--lib/events/roommemberevent.h23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h
index 8e0cc0a4..943d5ac6 100644
--- a/lib/events/roommemberevent.h
+++ b/lib/events/roommemberevent.h
@@ -22,8 +22,6 @@
#include "eventcontent.h"
-#include <QtCore/QUrl>
-
namespace QMatrixClient
{
class MemberEventContent: public EventContent::Base
@@ -36,6 +34,9 @@ namespace QMatrixClient
: membership(mt)
{ }
explicit MemberEventContent(const QJsonObject& json);
+ explicit MemberEventContent(const QJsonValue& jv)
+ : MemberEventContent(jv.toObject())
+ { }
MembershipType membership;
bool isDirect = false;
@@ -52,23 +53,26 @@ namespace QMatrixClient
{
Q_GADGET
public:
- static constexpr const char* typeId() { return "m.room.member"; }
+ DEFINE_EVENT_TYPEID("m.room.member", RoomMemberEvent)
using MembershipType = MemberEventContent::MembershipType;
- explicit RoomMemberEvent(Type type, const QJsonObject& obj)
- : StateEvent(type, obj)
+ explicit RoomMemberEvent(const QJsonObject& obj)
+ : StateEvent(typeId(), obj)
{ }
RoomMemberEvent(MemberEventContent&& c)
- : StateEvent(Type::RoomMember, c)
+ : StateEvent(typeId(), matrixTypeId(), c.toJson())
{ }
- explicit RoomMemberEvent(const QJsonObject& obj)
- : RoomMemberEvent(Type::RoomMember, obj)
+
+ // This is a special constructor enabling RoomMemberEvent to be
+ // a base class for more specific member events.
+ RoomMemberEvent(Type type, const QJsonObject& fullJson)
+ : StateEvent(type, fullJson)
{ }
MembershipType membership() const { return content().membership; }
QString userId() const
- { return originalJsonObject().value("state_key").toString(); }
+ { return fullJson()["state_key"_ls].toString(); }
bool isDirect() const { return content().isDirect; }
QString displayName() const { return content().displayName; }
QUrl avatarUrl() const { return content().avatarUrl; }
@@ -76,4 +80,5 @@ namespace QMatrixClient
private:
REGISTER_ENUM(MembershipType)
};
+ DEFINE_EVENTTYPE_ALIAS(RoomMember, RoomMemberEvent)
} // namespace QMatrixClient