Skip to content

Commit d86bea5

Browse files
committed
fix: Only include encrypt_state_events if we set it to true.
1 parent 7d8f991 commit d86bea5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/createRoom.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
Visibility,
2323
} from "matrix-js-sdk/src/matrix";
2424
import { logger } from "matrix-js-sdk/src/logger";
25+
import { type RoomEncryptionEventContent } from "matrix-js-sdk/src/types";
2526

2627
import Modal, { type IHandle } from "./Modal";
2728
import { _t, UserFriendlyError } from "./languageHandler";
@@ -211,13 +212,16 @@ export default async function createRoom(client: MatrixClient, opts: IOpts): Pro
211212
}
212213

213214
if (opts.encryption) {
215+
const content: RoomEncryptionEventContent = {
216+
algorithm: MEGOLM_ENCRYPTION_ALGORITHM,
217+
};
218+
if (opts.stateEncryption) {
219+
content["io.element.msc3414.encrypt_state_events"] = true;
220+
}
214221
createOpts.initial_state.push({
215222
type: "m.room.encryption",
216223
state_key: "",
217-
content: {
218-
"algorithm": MEGOLM_ENCRYPTION_ALGORITHM,
219-
"io.element.msc3414.encrypt_state_events": opts.stateEncryption,
220-
},
224+
content,
221225
});
222226
}
223227

0 commit comments

Comments
 (0)