Add command to reset the megolm session in a room

This commit is contained in:
Tulir Asokan
2020-10-05 22:32:15 +03:00
parent f21f57f09f
commit 0f17863708
3 changed files with 21 additions and 0 deletions

View File

@@ -123,6 +123,8 @@ func (handler *CommandHandler) CommandMux(ce *CommandEvent) {
handler.CommandDeletePortal(ce)
case "delete-all-portals":
handler.CommandDeleteAllPortals(ce)
case "discard-megolm-session", "discard-session":
handler.CommandDiscardMegolmSession(ce)
case "dev-test":
handler.CommandDevTest(ce)
case "set-pl":
@@ -163,6 +165,17 @@ func (handler *CommandHandler) CommandMux(ce *CommandEvent) {
}
}
func (handler *CommandHandler) CommandDiscardMegolmSession(ce *CommandEvent) {
if handler.bridge.Crypto == nil {
ce.Reply("This bridge instance doesn't have end-to-bridge encryption enabled")
} else if !ce.User.Admin {
ce.Reply("Only the bridge admin can reset Megolm sessions")
} else {
handler.bridge.Crypto.ResetSession(ce.RoomID)
ce.Reply("Successfully reset Megolm session in this room. New decryption keys will be shared the next time a message is sent from WhatsApp.")
}
}
func (handler *CommandHandler) CommandRelaybot(ce *CommandEvent) {
if handler.bridge.Relaybot == nil {
ce.Reply("The relaybot is disabled")