Discard session command only encrypted room

This commit is contained in:
Valere 2020-04-22 16:41:34 +02:00
parent 9b320ed3c7
commit d0f776a9cf
3 changed files with 13 additions and 2 deletions

View File

@ -44,7 +44,7 @@ enum class Command(val command: String, val parameters: String, @StringRes val d
POLL("/poll", "Question | Option 1 | Option 2 ...", R.string.command_description_poll), POLL("/poll", "Question | Option 1 | Option 2 ...", R.string.command_description_poll),
SHRUG("/shrug", "<message>", R.string.command_description_shrug), SHRUG("/shrug", "<message>", R.string.command_description_shrug),
PLAIN("/plain", "<message>", R.string.command_description_plain), PLAIN("/plain", "<message>", R.string.command_description_plain),
DISCARD_SESSION("/discardsession", "<message>", R.string.command_description_discard_session), DISCARD_SESSION("/discardsession","", R.string.command_description_discard_session),
// TODO temporary command // TODO temporary command
VERIFY_USER("/verify", "<user-id>", R.string.command_description_verify); VERIFY_USER("/verify", "<user-id>", R.string.command_description_verify);

View File

@ -448,7 +448,17 @@ class RoomDetailViewModel @AssistedInject constructor(
_viewEvents.post(RoomDetailViewEvents.SlashCommandNotImplemented) _viewEvents.post(RoomDetailViewEvents.SlashCommandNotImplemented)
} }
is ParsedCommand.DiscardSession -> { is ParsedCommand.DiscardSession -> {
session.cryptoService().discardOutbundSession(room.roomId) if (room.isEncrypted()) {
session.cryptoService().discardOutbundSession(room.roomId)
_viewEvents.post(RoomDetailViewEvents.SlashCommandHandled())
popDraft()
} else {
_viewEvents.post(RoomDetailViewEvents.SlashCommandHandled())
_viewEvents.post(
RoomDetailViewEvents
.ShowMessage(stringProvider.getString(R.string.command_description_discard_session_not_handled))
)
}
} }
}.exhaustive }.exhaustive
} }

View File

@ -7,6 +7,7 @@
<!-- BEGIN Strings added by Valere --> <!-- BEGIN Strings added by Valere -->
<string name="command_description_discard_session">Forces the current outbound group session in an encrypted room to be discarded</string> <string name="command_description_discard_session">Forces the current outbound group session in an encrypted room to be discarded</string>
<string name="command_description_discard_session_not_handled">Only supported in encrypted rooms</string>
<!-- END Strings added by Valere --> <!-- END Strings added by Valere -->