Skip to content

Commit

Permalink
code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fedrunov committed Jan 13, 2022
1 parent 9fa38c5 commit d92e0e4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion changelog.d/4865.misc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"/kick" command is replaced with "/remove"
"/kick" command is replaced with "/remove". Also replaced all occurrences in string resources
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CharSequence>?, val parameters: String, @StringRes val description: Int, val isDevCommand: Boolean) {
enum class Command(val command: String,
val aliases: Array<CharSequence>?,
val parameters: String,
@StringRes val description: Int,
val isDevCommand: Boolean) {
EMOTE("/me", null, "<message>", R.string.command_description_emote, false),
BAN_USER("/ban", null, "<user-id> [reason]", R.string.command_description_ban_user, false),
UNBAN_USER("/unban", null, "<user-id> [reason]", R.string.command_description_unban_user, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<string name="notice_direct_room_leave_by_you">You left the room</string>
<string name="notice_room_reject">%1$s rejected the invitation</string>
<string name="notice_room_reject_by_you">You rejected the invitation</string>
<!-- TODO: replace "kick" with "remove" in string resources keys -->
<string name="notice_room_kick">%1$s removed %2$s</string>
<string name="notice_room_kick_by_you">You removed %1$s</string>
<string name="notice_room_unban">%1$s unbanned %2$s</string>
Expand Down

0 comments on commit d92e0e4

Please sign in to comment.