diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-04-07 16:11:27 +0200 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-04-07 16:11:27 +0200 |
commit | 254c971106b8cc5603caea123803a70bc4bf2e6e (patch) | |
tree | b803c41e053a455047049ce7f5ee3a396d860b8b /lib/room.cpp | |
parent | fc2614d88ccc3c938ea69fd6a8f4978bc9663e16 (diff) | |
download | libquotient-254c971106b8cc5603caea123803a70bc4bf2e6e.tar.gz libquotient-254c971106b8cc5603caea123803a70bc4bf2e6e.zip |
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.
Diffstat (limited to 'lib/room.cpp')
-rw-r--r-- | lib/room.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
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<CallEventBase>()) + if (const auto* evt = it->viewAs<CallEventBase>()) 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)); |