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.
pull/21833/head
Damir Jelić 2020-05-26 21:27:45 +02:00
parent 403a64bcc6
commit 58f0814530
1 changed files with 8 additions and 1 deletions

View File

@ -507,7 +507,14 @@ export default class EventIndex extends EventEmitter {
try { try {
for (let i = 0; i < redactionEvents.length; i++) { for (let i = 0; i < redactionEvents.length; i++) {
const ev = redactionEvents[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( const eventsAlreadyAdded = await indexManager.addHistoricEvents(