aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-04-07 16:11:27 +0200
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-04-07 16:11:27 +0200
commit254c971106b8cc5603caea123803a70bc4bf2e6e (patch)
treeb803c41e053a455047049ce7f5ee3a396d860b8b /lib
parentfc2614d88ccc3c938ea69fd6a8f4978bc9663e16 (diff)
downloadlibquotient-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')
-rw-r--r--lib/room.cpp17
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));