aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-11-22 17:58:54 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-11-22 17:58:54 +0100
commit59ab0d5e04152e9657bdb47a6c9e860f4864be20 (patch)
tree8727242de1e5943f1a8469a45855f57125e91502 /lib/room.cpp
parente16ed41a6a28a43919126a85f7a802c5b2e091b6 (diff)
downloadlibquotient-59ab0d5e04152e9657bdb47a6c9e860f4864be20.tar.gz
libquotient-59ab0d5e04152e9657bdb47a6c9e860f4864be20.zip
Fix a crash on trying to mark unknown events as fully read
Diffstat (limited to 'lib/room.cpp')
-rw-r--r--lib/room.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index c166254e..e8d9b1bf 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -828,7 +828,10 @@ void Room::setReadReceipt(const QString& atEventId)
bool Room::Private::markMessagesAsRead(const rev_iter_t &upToMarker)
{
- if (const auto changes = setFullyReadMarker(upToMarker->event()->id())) {
+ if (upToMarker == q->historyEdge())
+ qCWarning(MESSAGES) << "Cannot mark an unknown event in"
+ << q->objectName() << "as fully read";
+ else if (const auto changes = setFullyReadMarker(upToMarker->event()->id())) {
// The assumption below is that if a read receipt was sent on a newer
// event, the homeserver will keep it there instead of reverting to
// m.fully_read
@@ -837,15 +840,11 @@ bool Room::Private::markMessagesAsRead(const rev_iter_t &upToMarker)
fullyReadUntilEventId);
postprocessChanges(changes);
return true;
- }
- if (upToMarker != q->historyEdge())
+ } else
qCDebug(MESSAGES) << "Event" << *upToMarker << "in" << q->objectName()
<< "is behind the current fully read marker at"
<< *q->fullyReadMarker()
<< "- won't move fully read marker back in timeline";
- else
- qCWarning(MESSAGES) << "Cannot mark an unknown event in"
- << q->objectName() << "as fully read";
return false;
}