diff --git a/libraries/slashcommands/impl/src/main/kotlin/io/element/android/libraries/slashcommands/impl/DefaultSlashCommandService.kt b/libraries/slashcommands/impl/src/main/kotlin/io/element/android/libraries/slashcommands/impl/DefaultSlashCommandService.kt index 6cd8688cad..8234116bb1 100644 --- a/libraries/slashcommands/impl/src/main/kotlin/io/element/android/libraries/slashcommands/impl/DefaultSlashCommandService.kt +++ b/libraries/slashcommands/impl/src/main/kotlin/io/element/android/libraries/slashcommands/impl/DefaultSlashCommandService.kt @@ -99,6 +99,14 @@ class DefaultSlashCommandService( override suspend fun proceedAdmin( slashCommand: SlashCommand.SlashCommandAdmin, ): Result { + if (slashCommand is SlashCommand.ChangeDisplayNameForRoom) { + val canUserChangeDisplayName = withTimeoutOrNull(5.seconds) { + capabilitiesProvider.canChangeDisplayName().getOrNull() + } ?: false + if (!canUserChangeDisplayName) { + return Result.failure(Exception("Changing display name is not allowed")) + } + } return commandExecutor.proceedAdmin( slashCommand = slashCommand, )