aboutsummaryrefslogtreecommitdiff
path: root/lib/events
diff options
context:
space:
mode:
Diffstat (limited to 'lib/events')
-rw-r--r--lib/events/roommemberevent.cpp32
-rw-r--r--lib/events/roommemberevent.h5
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/events/roommemberevent.cpp b/lib/events/roommemberevent.cpp
index 79e4af2d..eaa3302c 100644
--- a/lib/events/roommemberevent.cpp
+++ b/lib/events/roommemberevent.cpp
@@ -48,6 +48,7 @@ namespace QMatrixClient
return MembershipType::Undefined;
}
};
+
}
MemberEventContent::MemberEventContent(const QJsonObject& json)
@@ -68,3 +69,34 @@ void MemberEventContent::fillJson(QJsonObject* o) const
if (avatarUrl.isValid())
o->insert(QStringLiteral("avatar_url"), avatarUrl.toString());
}
+
+bool RoomMemberEvent::isInvite() const
+{
+ return membership() == MembershipType::Invite &&
+ (!prevContent() || prevContent()->membership != membership());
+}
+
+bool RoomMemberEvent::isJoin() const
+{
+ return membership() == MembershipType::Join &&
+ (!prevContent() || prevContent()->membership != membership());
+}
+
+bool RoomMemberEvent::isLeave() const
+{
+ return membership() == MembershipType::Leave &&
+ prevContent() && prevContent()->membership != membership() &&
+ prevContent()->membership != MembershipType::Ban;
+}
+
+bool RoomMemberEvent::isRename() const
+{
+ auto prevName = prevContent() ? prevContent()->displayName : QString();
+ return displayName() != prevName;
+}
+
+bool RoomMemberEvent::isAvatarUpdate() const
+{
+ auto prevAvatarUrl = prevContent() ? prevContent()->avatarUrl : QUrl();
+ return avatarUrl() != prevAvatarUrl;
+}
diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h
index f3e4f53a..db25d026 100644
--- a/lib/events/roommemberevent.h
+++ b/lib/events/roommemberevent.h
@@ -75,6 +75,11 @@ namespace QMatrixClient
bool isDirect() const { return content().isDirect; }
QString displayName() const { return content().displayName; }
QUrl avatarUrl() const { return content().avatarUrl; }
+ bool isInvite() const;
+ bool isJoin() const;
+ bool isLeave() const;
+ bool isRename() const;
+ bool isAvatarUpdate() const;
private:
REGISTER_ENUM(MembershipType)