From 58f0814530b22b5a03f10e74ee18827ea60100a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 26 May 2020 21:27:45 +0200 Subject: [PATCH] EventIndex: Handle invalid m.room.redaction events correctly. Clients might send invalid redaction events, such events will not have a valid redacts field containing the event id of the associated event that was redacted. Skip such events instead of ending up looping over the checkpoint forever. --- src/indexing/EventIndex.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/indexing/EventIndex.js b/src/indexing/EventIndex.js index a02e378d8e..b0dd811e0c 100644 --- a/src/indexing/EventIndex.js +++ b/src/indexing/EventIndex.js @@ -507,7 +507,14 @@ export default class EventIndex extends EventEmitter { try { for (let i = 0; i < redactionEvents.length; i++) { const ev = redactionEvents[i]; - await indexManager.deleteEvent(ev.getAssociatedId()); + const eventId = ev.getAssociatedId(); + + if (eventId) { + await indexManager.deleteEvent(eventId); + } else { + console.log("EventIndex: Redaction event doesn't contain a", + "valid associated event id", ev); + } } const eventsAlreadyAdded = await indexManager.addHistoricEvents(