aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-03-04 14:59:57 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-06-27 07:15:45 +0200
commit45d9745fd9c093875e67e92cd69543adfc707644 (patch)
tree3f2a9bd8f8527634be305ac0d4c0412075ae3953 /lib
parent780d1b61c37a89f93eb58fb271083444f775acd2 (diff)
downloadlibquotient-45d9745fd9c093875e67e92cd69543adfc707644.tar.gz
libquotient-45d9745fd9c093875e67e92cd69543adfc707644.zip
Room::processEphemeralEvents(): refactoring
Diffstat (limited to 'lib')
-rw-r--r--lib/room.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index a5940eb2..7b60a77d 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -2632,27 +2632,22 @@ Room::Changes Room::processEphemeralEvent(EventPtr&& event)
<< p.receipts.size() << "users";
}
const auto newMarker = findInTimeline(p.evtId);
- if (newMarker != timelineEdge()) {
- for (const Receipt& r : p.receipts) {
- if (r.userId == connection()->userId())
- continue; // FIXME, #185
- auto* const u = user(r.userId);
- if (u && memberJoinState(u) == JoinState::Join)
- changes |= d->promoteReadMarker(u, newMarker);
- }
- } else {
+ if (newMarker != timelineEdge())
qCDebug(EPHEMERAL) << "Event" << p.evtId
<< "not found; saving read receipts anyway";
- // If the event is not found (most likely, because it's too old
- // and hasn't been fetched from the server yet), but there is
- // a previous marker for a user, keep the previous marker.
- // Otherwise, blindly store the event id for this user.
- for (const Receipt& r : p.receipts) {
- if (r.userId == connection()->userId())
- continue; // FIXME, #185
- auto* const u = user(r.userId);
- if (u && memberJoinState(u) == JoinState::Join
- && readMarker(u) == timelineEdge())
+ for (const Receipt& r : p.receipts) {
+ auto* const u = user(r.userId);
+ if (u == localUser())
+ continue; // The local user has m.fully_read but FIXME: #464
+ if (u && memberJoinState(u) == JoinState::Join) {
+ // If the event is not found (most likely, because it's
+ // too old and hasn't been fetched from the server yet)
+ // but there is a previous marker for a user, keep
+ // the previous marker (XXX: why??). Otherwise, blindly
+ // store the event id for this user.
+ if (newMarker != timelineEdge())
+ changes |= d->promoteReadMarker(u, newMarker);
+ else if (readMarker(u) == timelineEdge())
changes |= d->setLastReadEvent(u, p.evtId);
}
}