1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-06 12:02:40 +03:00

Simplify code paths for building to-device MatrixEvents (#4729)

We don't need all the complicated stuff when we have a to-device event, so
let's simplify.
This commit is contained in:
Richard van der Hoff
2025-02-24 17:51:42 +00:00
committed by GitHub
parent bcaa7f63c7
commit ea770282ea
3 changed files with 12 additions and 11 deletions

View File

@@ -25,7 +25,8 @@ export interface MapperOpts {
preventReEmit?: boolean;
// decrypt event proactively
decrypt?: boolean;
// the event is a to_device event
/** @deprecated no longer used */
toDevice?: boolean;
}
@@ -34,10 +35,6 @@ export function eventMapperFor(client: MatrixClient, options: MapperOpts): Event
const decrypt = options.decrypt !== false;
function mapper(plainOldJsObject: Partial<IEvent>): MatrixEvent {
if (options.toDevice) {
delete plainOldJsObject.room_id;
}
const room = client.getRoom(plainOldJsObject.room_id);
let event: MatrixEvent | undefined;
@@ -74,9 +71,6 @@ export function eventMapperFor(client: MatrixClient, options: MapperOpts): Event
event.setThread(thread);
}
// TODO: once we get rid of the old libolm-backed crypto, we can restrict this to room events (rather than
// to-device events), because the rust implementation decrypts to-device messages at a higher level.
// Generally we probably want to use a different eventMapper implementation for to-device events because
if (event.isEncrypted()) {
if (!preventReEmit) {
client.reEmitter.reEmit(event, [MatrixEventEvent.Decrypted]);