From 254c971106b8cc5603caea123803a70bc4bf2e6e Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 7 Apr 2020 16:11:27 +0200 Subject: Room::addNewMessageEvents: fix an assertion failure on empty sender When a message is redacted it has no sender. If it happens to be in the bulkhead, Quotient tries to promote a read marker over it and fails on being unable to resolve the author. --- lib/room.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lib/room.cpp') diff --git a/lib/room.cpp b/lib/room.cpp index 16f81813..5d4e2141 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -2309,7 +2309,7 @@ Room::Changes Room::Private::addNewMessageEvents(RoomEvents&& events) if (q->supportsCalls()) for (auto it = from; it != timeline.cend(); ++it) - if (auto* evt = it->viewAs()) + if (const auto* evt = it->viewAs()) emit q->callEvent(q, evt); if (totalInserted > 0) { @@ -2331,12 +2331,15 @@ Room::Changes Room::Private::addNewMessageEvents(RoomEvents&& events) // read receipts from the server (or, for the local user, // markMessagesAsRead() invocation) to promote their read markers over // the new message events. - auto firstWriter = q->user((*from)->senderId()); - if (q->readMarker(firstWriter) != timeline.crend()) { - roomChanges |= promoteReadMarker(firstWriter, rev_iter_t(from) - 1); - qCDebug(STATE) << "Auto-promoted read marker for" - << firstWriter->id() << "to" - << *q->readMarker(firstWriter); + if (const auto senderId = (*from)->senderId(); !senderId.isEmpty()) { + auto* const firstWriter = q->user(senderId); + if (q->readMarker(firstWriter) != timeline.crend()) { + roomChanges |= + promoteReadMarker(firstWriter, rev_iter_t(from) - 1); + qCDebug(STATE) + << "Auto-promoted read marker for" << senderId + << "to" << *q->readMarker(firstWriter); + } } updateUnreadCount(timeline.crbegin(), rev_iter_t(from)); -- cgit v1.2.3