From 77f1ca99ade62565ce30758005b911eb340953e6 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 8 Dec 2019 20:19:25 +0300 Subject: Room::addNewMessageEvents: search the whole sync batch for events to redact It seems that sometimes redactions may precede the unredacted events within the same sync batch. --- lib/room.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'lib/room.cpp') diff --git a/lib/room.cpp b/lib/room.cpp index be07ce50..198cef0d 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -2122,12 +2122,10 @@ Room::Changes Room::Private::addNewMessageEvents(RoomEvents&& events) // Try to find the target in the timeline, then in the batch. if (processRedaction(*r)) continue; - auto targetIt = std::find_if(events.begin(), it, - [id = r->redactedEvent()]( - const RoomEventPtr& ep) { - return ep->id() == id; - }); - if (targetIt != it) + if (auto targetIt = std::find_if(events.begin(), events.end(), + [id = r->redactedEvent()](const RoomEventPtr& ep) { + return ep->id() == id; + }); targetIt != events.end()) *targetIt = makeRedacted(**targetIt, *r); else qCDebug(EVENTS) -- cgit v1.2.3