From d92e0e48f68d3c4b7b4d50e219701146106e9a68 Mon Sep 17 00:00:00 2001 From: fedrunov Date: Thu, 13 Jan 2022 17:50:38 +0100 Subject: [PATCH] code review changes --- changelog.d/4865.misc | 2 +- .../api/session/room/members/MembershipService.kt | 5 ++++- .../java/im/vector/app/features/command/Command.kt | 6 +++++- .../im/vector/app/features/command/CommandParser.kt | 12 ++++++++++-- vector/src/main/res/values/strings.xml | 1 + 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/changelog.d/4865.misc b/changelog.d/4865.misc index a253ab24c7..291c4a099f 100644 --- a/changelog.d/4865.misc +++ b/changelog.d/4865.misc @@ -1 +1 @@ -"/kick" command is replaced with "/remove" \ No newline at end of file +"/kick" command is replaced with "/remove". Also replaced all occurrences in string resources diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/members/MembershipService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/members/MembershipService.kt index 6dacd9cfd1..d5bc65c142 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/members/MembershipService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/members/MembershipService.kt @@ -75,10 +75,13 @@ interface MembershipService { suspend fun unban(userId: String, reason: String? = null) /** - * Kick a user from the room + * Remove a user from the room */ suspend fun remove(userId: String, reason: String? = null) + @Deprecated("Use remove instead", ReplaceWith("remove(userId, reason)")) + suspend fun kick(userId: String, reason: String? = null) = remove(userId, reason) + /** * Join the room, or accept an invitation. */ diff --git a/vector/src/main/java/im/vector/app/features/command/Command.kt b/vector/src/main/java/im/vector/app/features/command/Command.kt index 385cf1f3db..f7390282f2 100644 --- a/vector/src/main/java/im/vector/app/features/command/Command.kt +++ b/vector/src/main/java/im/vector/app/features/command/Command.kt @@ -24,7 +24,11 @@ import im.vector.app.R * the user can write theses messages to perform some actions * the list will be displayed in this order */ -enum class Command(val command: String, val aliases: Array?, val parameters: String, @StringRes val description: Int, val isDevCommand: Boolean) { +enum class Command(val command: String, + val aliases: Array?, + val parameters: String, + @StringRes val description: Int, + val isDevCommand: Boolean) { EMOTE("/me", null, "", R.string.command_description_emote, false), BAN_USER("/ban", null, " [reason]", R.string.command_description_ban_user, false), UNBAN_USER("/unban", null, " [reason]", R.string.command_description_unban_user, false), diff --git a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt index c6de96859a..f5861c7c53 100644 --- a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt +++ b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt @@ -370,10 +370,18 @@ object CommandParser { } } Command.ADD_TO_SPACE.matches(slashCommand) -> { - ParsedCommand.AddToSpace(spaceId = message) + if (messageParts.size == 1) { + ParsedCommand.AddToSpace(spaceId = message) + } else { + ParsedCommand.ErrorSyntax(Command.ADD_TO_SPACE) + } } Command.JOIN_SPACE.matches(slashCommand) -> { - ParsedCommand.JoinSpace(spaceIdOrAlias = message) + if (messageParts.size == 1) { + ParsedCommand.JoinSpace(spaceIdOrAlias = message) + } else { + ParsedCommand.ErrorSyntax(Command.JOIN_SPACE) + } } Command.LEAVE_ROOM.matches(slashCommand) -> { ParsedCommand.LeaveRoom(roomId = message) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 11a3eb0a0d..265758c673 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -25,6 +25,7 @@ You left the room %1$s rejected the invitation You rejected the invitation + %1$s removed %2$s You removed %1$s %1$s unbanned %2$s