Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RoomMemberEvent: add isRejectedInvite(), isBan() and isUnban() #320

Merged
merged 1 commit into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
KitsuneRal marked this conversation as resolved.
Show resolved Hide resolved

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