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

Commit b6a50ee

Browse files
authored
Add a developer command to reset Megolm and Olm sessions (#9044)
Useful when debugging crypto setup.
1 parent 62f3a9a commit b6a50ee

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/SlashCommands.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,28 @@ export const Commands = [
10701070
category: CommandCategories.advanced,
10711071
renderingTypes: [TimelineRenderingType.Room],
10721072
}),
1073+
new Command({
1074+
command: 'remakeolm',
1075+
description: _td('Developer command: Discards the current outbound group session and sets up new Olm sessions'),
1076+
isEnabled: () => {
1077+
return SettingsStore.getValue("developerMode");
1078+
},
1079+
runFn: (roomId) => {
1080+
try {
1081+
const room = MatrixClientPeg.get().getRoom(roomId);
1082+
1083+
MatrixClientPeg.get().forceDiscardSession(roomId);
1084+
1085+
// noinspection JSIgnoredPromiseFromCall
1086+
MatrixClientPeg.get().crypto.ensureOlmSessionsForUsers(room.getMembers().map(m => m.userId), true);
1087+
} catch (e) {
1088+
return reject(e.message);
1089+
}
1090+
return success();
1091+
},
1092+
category: CommandCategories.advanced,
1093+
renderingTypes: [TimelineRenderingType.Room],
1094+
}),
10731095
new Command({
10741096
command: "rainbow",
10751097
description: _td("Sends the given message coloured as a rainbow"),

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@
445445
"Verified key": "Verified key",
446446
"The signing key you provided matches the signing key you received from %(userId)s's session %(deviceId)s. Session marked as verified.": "The signing key you provided matches the signing key you received from %(userId)s's session %(deviceId)s. Session marked as verified.",
447447
"Forces the current outbound group session in an encrypted room to be discarded": "Forces the current outbound group session in an encrypted room to be discarded",
448+
"Developer command: Discards the current outbound group session and sets up new Olm sessions": "Developer command: Discards the current outbound group session and sets up new Olm sessions",
448449
"Sends the given message coloured as a rainbow": "Sends the given message coloured as a rainbow",
449450
"Sends the given emote coloured as a rainbow": "Sends the given emote coloured as a rainbow",
450451
"Displays list of commands with usages and descriptions": "Displays list of commands with usages and descriptions",

0 commit comments

Comments
 (0)