Skip to content

Commit

Permalink
Merge pull request #320 from krkk/roommemberevent-types
Browse files Browse the repository at this point in the history
RoomMemberEvent: add isRejectedInvite(), isBan() and isUnban()
  • Loading branch information
KitsuneRal authored Mar 9, 2020
2 parents d3ca82b + 4f027cf commit ef81c79
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/events/roommemberevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/events/roommemberevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ class RoomMemberEvent : public StateEvent<MemberEventContent> {
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;
Expand Down

0 comments on commit ef81c79

Please sign in to comment.