diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-03-29 13:26:36 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-03-30 16:19:32 +0900 |
commit | a28892ca3b40a32556ee7615116c322f6b2a4ae5 (patch) | |
tree | 2e666bb9e997a77b0dee03a315181420f0a61048 /lib/user.cpp | |
parent | 01c5a35398a55dfc4a30e466aeb13419387555d3 (diff) | |
download | libquotient-a28892ca3b40a32556ee7615116c322f6b2a4ae5.tar.gz libquotient-a28892ca3b40a32556ee7615116c322f6b2a4ae5.zip |
Room::processStateEvent, User: take the previous membership state from oldStateEvent
memberJoinState() just happens to return the not-yet-updated state,
making its use around state changes very sensitive to moving things
around. The event's own prevContent is unsigned, therefore untrusted.
Diffstat (limited to 'lib/user.cpp')
-rw-r--r-- | lib/user.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/user.cpp b/lib/user.cpp index 93cfbffd..c373a067 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -379,19 +379,18 @@ QUrl User::avatarUrl(const Room* room) const return avatarObject(room).url(); } -void User::processEvent(const RoomMemberEvent& event, const Room* room) +void User::processEvent(const RoomMemberEvent& event, const Room* room, + bool firstMention) { Q_ASSERT(room); + + if (firstMention) + ++d->totalRooms; + if (event.membership() != MembershipType::Invite && event.membership() != MembershipType::Join) return; - auto aboutToEnter = room->memberJoinState(this) == JoinState::Leave && - (event.membership() == MembershipType::Join || - event.membership() == MembershipType::Invite); - if (aboutToEnter) - ++d->totalRooms; - auto newName = event.displayName(); // `bridged` value uses the same notification signal as the name; // it is assumed that first setting of the bridge occurs together with |