Avoid MatrixEvent.toJSON in event indexer (#11765)

Part of the solution to https://github.com/vector-im/element-web/issues/26380:
`toJSON` is dangerous, and I'd like to kill it off. There is no need for it
here; it is simpler to call `getEffectiveEvent` directly.
This commit is contained in:
Richard van der Hoff 2023-10-17 16:54:22 +01:00 committed by GitHub
parent 49cfde82de
commit a283bc4889
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -309,8 +309,7 @@ export default class EventIndex extends EventEmitter {
}
private eventToJson(ev: MatrixEvent): IEventWithRoomId {
const jsonEvent: any = ev.toJSON();
const e = ev.isEncrypted() ? jsonEvent.decrypted : jsonEvent;
const e = ev.getEffectiveEvent() as any;
if (ev.isEncrypted()) {
// Let us store some additional data so we can re-verify the event.