mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 06:28:45 +03:00
parsing the space commands by checking for the size and last segment to find the space id to join/add to
This commit is contained in:
parent
da70d520bc
commit
493d9240c2
3 changed files with 16 additions and 4 deletions
1
changelog.d/6844.bugfix
Normal file
1
changelog.d/6844.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fixes /addToSpace and /joinSpace commands showing invalid syntax warnings
|
|
@ -374,15 +374,15 @@ class CommandParser @Inject constructor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command.ADD_TO_SPACE.matches(slashCommand) -> {
|
Command.ADD_TO_SPACE.matches(slashCommand) -> {
|
||||||
if (messageParts.size == 1) {
|
if (messageParts.size == 2) {
|
||||||
ParsedCommand.AddToSpace(spaceId = message)
|
ParsedCommand.AddToSpace(spaceId = messageParts.last())
|
||||||
} else {
|
} else {
|
||||||
ParsedCommand.ErrorSyntax(Command.ADD_TO_SPACE)
|
ParsedCommand.ErrorSyntax(Command.ADD_TO_SPACE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command.JOIN_SPACE.matches(slashCommand) -> {
|
Command.JOIN_SPACE.matches(slashCommand) -> {
|
||||||
if (messageParts.size == 1) {
|
if (messageParts.size == 2) {
|
||||||
ParsedCommand.JoinSpace(spaceIdOrAlias = message)
|
ParsedCommand.JoinSpace(spaceIdOrAlias = messageParts.last())
|
||||||
} else {
|
} else {
|
||||||
ParsedCommand.ErrorSyntax(Command.JOIN_SPACE)
|
ParsedCommand.ErrorSyntax(Command.JOIN_SPACE)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ package im.vector.app.features.command
|
||||||
import org.amshove.kluent.shouldBeEqualTo
|
import org.amshove.kluent.shouldBeEqualTo
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
|
private const val A_SPACE_ID = "!my-space-id"
|
||||||
|
|
||||||
class CommandParserTest {
|
class CommandParserTest {
|
||||||
@Test
|
@Test
|
||||||
fun parseSlashCommandEmpty() {
|
fun parseSlashCommandEmpty() {
|
||||||
|
@ -31,6 +33,15 @@ class CommandParserTest {
|
||||||
test("/unknown with param", ParsedCommand.ErrorUnknownSlashCommand("/unknown"))
|
test("/unknown with param", ParsedCommand.ErrorUnknownSlashCommand("/unknown"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun parseSlashAddToSpaceCommand() {
|
||||||
|
test("/addToSpace $A_SPACE_ID", ParsedCommand.AddToSpace(A_SPACE_ID))
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
fun parseSlashJoinSpaceCommand() {
|
||||||
|
test("/joinSpace $A_SPACE_ID", ParsedCommand.JoinSpace(A_SPACE_ID))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun parseSlashCommandNotACommand() {
|
fun parseSlashCommandNotACommand() {
|
||||||
test("", ParsedCommand.ErrorNotACommand)
|
test("", ParsedCommand.ErrorNotACommand)
|
||||||
|
|
Loading…
Reference in a new issue