Skip to content

Commit

Permalink
Wire up rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Oct 17, 2023
1 parent 5595e84 commit 760b57e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/rust-crypto/RoomEncryptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,18 @@ export class RoomEncryptor {
this.prefixedLogger.debug("Sessions for users are ready; now sharing room key");

const rustEncryptionSettings = new EncryptionSettings();
/* FIXME historyVisibility, rotation, etc */
/* FIXME historyVisibility, etc */

// We need to convert the rotation period from milliseconds to microseconds
// See https://spec.matrix.org/v1.8/client-server-api/#mroomencryption and
// https://matrix-org.github.io/matrix-rust-sdk-crypto-wasm/classes/EncryptionSettings.html#rotationPeriod
if (typeof this.encryptionSettings.rotation_period_ms === "number") {
rustEncryptionSettings.rotationPeriod = BigInt(this.encryptionSettings.rotation_period_ms * 1000);
}

if (typeof this.encryptionSettings.rotation_period_msgs === "number") {
rustEncryptionSettings.rotationPeriodMessages = BigInt(this.encryptionSettings.rotation_period_msgs);
}

const shareMessages = await this.olmMachine.shareRoomKey(
new RoomId(this.room.roomId),
Expand Down

0 comments on commit 760b57e

Please sign in to comment.