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.
This commit is contained in:
Damir Jelić 2020-05-26 21:27:45 +02:00
parent 403a64bcc6
commit 58f0814530

View file

@ -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(