mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Add /myroomnick slash command
This commit is contained in:
+1
-1
@@ -109,7 +109,7 @@ enum class Command(
|
||||
parameters = "<display-name>",
|
||||
description = R.string.slash_command_description_nick_for_room,
|
||||
isAllowedInThread = false,
|
||||
isSupported = false,
|
||||
isSupported = true,
|
||||
),
|
||||
ROOM_AVATAR(
|
||||
command = "/roomavatar",
|
||||
|
||||
+3
-3
@@ -47,7 +47,7 @@ class CommandExecutor(
|
||||
is SlashCommand.ChangeAvatar -> changeAvatar()
|
||||
is SlashCommand.ChangeAvatarForRoom -> changeAvatarForRoom()
|
||||
is SlashCommand.ChangeDisplayName -> changeDisplayName(slashCommand)
|
||||
is SlashCommand.ChangeDisplayNameForRoom -> changeDisplayNameForRoom()
|
||||
is SlashCommand.ChangeDisplayNameForRoom -> changeDisplayNameForRoom(slashCommand)
|
||||
is SlashCommand.ChangeRoomAvatar -> changeRoomAvatar()
|
||||
is SlashCommand.ChangeRoomName -> changeRoomName(slashCommand)
|
||||
is SlashCommand.ChangeTopic -> changeTopic(slashCommand)
|
||||
@@ -171,8 +171,8 @@ class CommandExecutor(
|
||||
return Result.failure(Exception("Not yet implemented"))
|
||||
}
|
||||
|
||||
private fun changeDisplayNameForRoom(): Result<Unit> {
|
||||
return Result.failure(Exception("Not yet implemented"))
|
||||
private suspend fun changeDisplayNameForRoom(slashCommand: SlashCommand.ChangeDisplayNameForRoom): Result<Unit> {
|
||||
return joinedRoom.setOwnMemberDisplayName(slashCommand.displayName)
|
||||
}
|
||||
|
||||
private suspend fun changeDisplayName(slashCommand: SlashCommand.ChangeDisplayName): Result<Unit> {
|
||||
|
||||
+12
-4
@@ -185,10 +185,18 @@ class CommandExecutorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `change display name for room is not supported`() = runTest {
|
||||
val sut = createCommandExecutor()
|
||||
val res = sut.proceedAdmin(SlashCommand.ChangeDisplayNameForRoom(A_USER_NAME))
|
||||
assertThat(res.isFailure).isTrue()
|
||||
fun `change display name for room delegates to joined room`() = runTest {
|
||||
var capturedDisplayName: String? = null
|
||||
val joinedRoom = FakeJoinedRoom(
|
||||
setOwnMemberDisplayNameResult = { displayName ->
|
||||
capturedDisplayName = displayName
|
||||
Result.success(Unit)
|
||||
}
|
||||
)
|
||||
val sut = createCommandExecutor(joinedRoom = joinedRoom)
|
||||
val res = sut.proceedAdmin(SlashCommand.ChangeDisplayNameForRoom("room nick"))
|
||||
assertThat(res.isSuccess).isTrue()
|
||||
assertThat(capturedDisplayName).isEqualTo("room nick")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user