aboutsummaryrefslogtreecommitdiff
path: root/lib/events
diff options
context:
space:
mode:
Diffstat (limited to 'lib/events')
-rw-r--r--lib/events/roommemberevent.cpp14
-rw-r--r--lib/events/roommemberevent.h7
2 files changed, 15 insertions, 6 deletions
diff --git a/lib/events/roommemberevent.cpp b/lib/events/roommemberevent.cpp
index d0787170..d4b2be45 100644
--- a/lib/events/roommemberevent.cpp
+++ b/lib/events/roommemberevent.cpp
@@ -52,6 +52,7 @@ MemberEventContent::MemberEventContent(const QJsonObject& json)
, isDirect(json["is_direct"_ls].toBool())
, displayName(sanitized(json["displayname"_ls].toString()))
, avatarUrl(json["avatar_url"_ls].toString())
+ , reason(json["reason"_ls].toString())
{}
void MemberEventContent::fillJson(QJsonObject* o) const
@@ -64,18 +65,23 @@ void MemberEventContent::fillJson(QJsonObject* o) const
o->insert(QStringLiteral("displayname"), displayName);
if (avatarUrl.isValid())
o->insert(QStringLiteral("avatar_url"), avatarUrl.toString());
+ if (!reason.isEmpty())
+ o->insert(QStringLiteral("reason"), reason);
+}
+
+bool RoomMemberEvent::changesMembership() const
+{
+ return !prevContent() || prevContent()->membership != membership();
}
bool RoomMemberEvent::isInvite() const
{
- return membership() == MembershipType::Invite
- && (!prevContent() || prevContent()->membership != membership());
+ return membership() == MembershipType::Invite && changesMembership();
}
bool RoomMemberEvent::isJoin() const
{
- return membership() == MembershipType::Join
- && (!prevContent() || prevContent()->membership != membership());
+ return membership() == MembershipType::Join && changesMembership();
}
bool RoomMemberEvent::isLeave() const
diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h
index 6a34fd7f..0ca439e1 100644
--- a/lib/events/roommemberevent.h
+++ b/lib/events/roommemberevent.h
@@ -40,6 +40,7 @@ public:
bool isDirect = false;
QString displayName;
QUrl avatarUrl;
+ QString reason;
protected:
void fillJson(QJsonObject* o) const override;
@@ -56,8 +57,8 @@ public:
explicit RoomMemberEvent(const QJsonObject& obj) : StateEvent(typeId(), obj)
{}
- [[deprecated("Use RoomMemberEvent(userId, contentArgs) "
- "instead")]] RoomMemberEvent(MemberEventContent&& c)
+ [[deprecated("Use RoomMemberEvent(userId, contentArgs) instead")]]
+ RoomMemberEvent(MemberEventContent&& c)
: StateEvent(typeId(), matrixTypeId(), QString(), c)
{}
template <typename... ArgTs>
@@ -85,6 +86,8 @@ public:
bool isDirect() const { return content().isDirect; }
QString displayName() const { return content().displayName; }
QUrl avatarUrl() const { return content().avatarUrl; }
+ QString reason() const { return content().reason; }
+ bool changesMembership() const;
bool isInvite() const;
bool isJoin() const;
bool isLeave() const;