Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Avoid MatrixEvent.toJSON in event indexer (#11765)
Browse files Browse the repository at this point in the history
Part of the solution to element-hq/element-web#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.
  • Loading branch information
richvdh authored Oct 17, 2023
1 parent 49cfde8 commit a283bc4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/indexing/EventIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a283bc4

Please sign in to comment.