From 4f027cf952e2458d2301236d43b4c9fbcdba345b Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Wed, 15 May 2019 20:51:06 +0200 Subject: [PATCH] RoomMemberEvent: add isRejectedInvite(), isBan(), and isUnban() --- lib/events/roommemberevent.cpp | 20 +++++++++++++++++++- lib/events/roommemberevent.h | 3 +++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/events/roommemberevent.cpp b/lib/events/roommemberevent.cpp index d4b2be45d..35cbdb3a5 100644 --- a/lib/events/roommemberevent.cpp +++ b/lib/events/roommemberevent.cpp @@ -79,6 +79,12 @@ bool RoomMemberEvent::isInvite() const return membership() == MembershipType::Invite && changesMembership(); } +bool RoomMemberEvent::isRejectedInvite() const +{ + return membership() == MembershipType::Leave && prevContent() + && prevContent()->membership == MembershipType::Invite; +} + bool RoomMemberEvent::isJoin() const { return membership() == MembershipType::Join && changesMembership(); @@ -88,7 +94,19 @@ bool RoomMemberEvent::isLeave() const { return membership() == MembershipType::Leave && prevContent() && prevContent()->membership != membership() - && prevContent()->membership != MembershipType::Ban; + && prevContent()->membership != MembershipType::Ban + && prevContent()->membership != MembershipType::Invite; +} + +bool RoomMemberEvent::isBan() const +{ + return membership() == MembershipType::Ban && changesMembership(); +} + +bool RoomMemberEvent::isUnban() const +{ + return membership() == MembershipType::Leave && prevContent() + && prevContent()->membership == MembershipType::Ban; } bool RoomMemberEvent::isRename() const diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h index 0ca439e1c..783b8207f 100644 --- a/lib/events/roommemberevent.h +++ b/lib/events/roommemberevent.h @@ -88,7 +88,10 @@ class RoomMemberEvent : public StateEvent { QUrl avatarUrl() const { return content().avatarUrl; } QString reason() const { return content().reason; } bool changesMembership() const; + bool isBan() const; + bool isUnban() const; bool isInvite() const; + bool isRejectedInvite() const; bool isJoin() const; bool isLeave() const; bool isRename() const;