From ab45e1aee912cf242caea2d762b2b27c83a0e972 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 5 Oct 2016 14:30:45 +0900 Subject: Check there are no non-members "typing" or "having read" messages Normally, this shouldn't happen anyway - just a double-check, --- room.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/room.cpp b/room.cpp index e559bc37..c693898f 100644 --- a/room.cpp +++ b/room.cpp @@ -452,6 +452,7 @@ void Room::processStateEvents(const Events& events) if( event->type() == EventType::RoomMember ) { RoomMemberEvent* memberEvent = static_cast(event); + // Can't use d->member() below because the user may be not a member (yet) User* u = d->connection->user(memberEvent->userId()); u->processEvent(event); if( memberEvent->membership() == MembershipType::Join ) @@ -472,9 +473,10 @@ void Room::processEphemeralEvent(Event* event) { TypingEvent* typingEvent = static_cast(event); d->usersTyping.clear(); - for( const QString& user: typingEvent->users() ) + for( const QString& userId: typingEvent->users() ) { - d->usersTyping.append(d->connection->user(user)); + if (auto m = d->member(userId)) + d->usersTyping.append(m); } emit typingChanged(); } @@ -486,7 +488,8 @@ void Room::processEphemeralEvent(Event* event) const auto receipts = receiptEvent->receiptsForEvent(eventId); for( const Receipt& r: receipts ) { - d->lastReadEvent.insert(d->connection->user(r.userId), eventId); + if (auto m = d->member(r.userId)) + d->lastReadEvent.insert(m, eventId); } } } -- cgit v1.2.3