From 57354cbd69f77612ed1da48590647b1272aea0a4 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 4 Dec 2019 20:11:19 +0100 Subject: [PATCH] Add reason to slash commands --- .../main/java/im/vector/matrix/rx/RxRoom.kt | 4 +- .../java/im/vector/matrix/rx/RxSession.kt | 4 +- .../api/session/room/RoomDirectoryService.kt | 2 +- .../android/api/session/room/RoomService.kt | 2 + .../session/room/members/MembershipService.kt | 6 +- .../room/DefaultRoomDirectoryService.kt | 4 +- .../session/room/DefaultRoomService.kt | 4 +- .../android/internal/session/room/RoomAPI.kt | 4 +- .../membership/DefaultMembershipService.kt | 12 ++-- .../room/membership/joining/InviteBody.kt | 3 +- .../room/membership/joining/InviteTask.kt | 5 +- .../room/membership/joining/JoinRoomTask.kt | 3 +- .../room/membership/leaving/LeaveRoomTask.kt | 5 +- .../vector/riotx/features/command/Command.kt | 8 +-- .../riotx/features/command/CommandParser.kt | 72 +++++++++++++------ .../riotx/features/command/ParsedCommand.kt | 12 ++-- .../home/room/detail/RoomDetailViewModel.kt | 8 +-- .../home/room/list/RoomListViewModel.kt | 6 +- .../NotificationBroadcastReceiver.kt | 4 +- .../roomdirectory/RoomDirectoryViewModel.kt | 2 +- .../roompreview/RoomPreviewViewModel.kt | 2 +- 21 files changed, 105 insertions(+), 67 deletions(-) diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt index 6793d6249d..96f2de9cdc 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt @@ -57,8 +57,8 @@ class RxRoom(private val room: Room) { room.loadRoomMembersIfNeeded(MatrixCallbackSingle(it)).toSingle(it) } - fun joinRoom(viaServers: List = emptyList()): Single = Single.create { - room.join(viaServers, MatrixCallbackSingle(it)).toSingle(it) + fun joinRoom(reason: String?, viaServers: List = emptyList()): Single = Single.create { + room.join(reason, viaServers, MatrixCallbackSingle(it)).toSingle(it) } fun liveEventReadReceipts(eventId: String): Observable> { diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt index 1964d05a1b..1ef1c8cadb 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt @@ -76,8 +76,8 @@ class RxSession(private val session: Session) { session.searchUsersDirectory(search, limit, excludedUserIds, MatrixCallbackSingle(it)).toSingle(it) } - fun joinRoom(roomId: String, viaServers: List = emptyList()): Single = Single.create { - session.joinRoom(roomId, viaServers, MatrixCallbackSingle(it)).toSingle(it) + fun joinRoom(roomId: String, reason: String?, viaServers: List = emptyList()): Single = Single.create { + session.joinRoom(roomId, reason, viaServers, MatrixCallbackSingle(it)).toSingle(it) } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomDirectoryService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomDirectoryService.kt index 930320d976..8d03c70efa 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomDirectoryService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomDirectoryService.kt @@ -35,7 +35,7 @@ interface RoomDirectoryService { /** * Join a room by id */ - fun joinRoom(roomId: String, callback: MatrixCallback): Cancelable + fun joinRoom(roomId: String, reason: String?, callback: MatrixCallback): Cancelable /** * Fetches the overall metadata about protocols supported by the homeserver. diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomService.kt index 2dbb580a4f..71a9a8e4fa 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomService.kt @@ -35,9 +35,11 @@ interface RoomService { /** * Join a room by id * @param roomId the roomId of the room to join + * @param reason optional reason for joining the room * @param viaServers the servers to attempt to join the room through. One of the servers must be participating in the room. */ fun joinRoom(roomId: String, + reason: String?, viaServers: List = emptyList(), callback: MatrixCallback): Cancelable diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/members/MembershipService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/members/MembershipService.kt index 8d60bee9da..0f487880b7 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/members/MembershipService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/members/MembershipService.kt @@ -52,16 +52,16 @@ interface MembershipService { /** * Invite a user in the room */ - fun invite(userId: String, callback: MatrixCallback): Cancelable + fun invite(userId: String, reason: String?, callback: MatrixCallback): Cancelable /** * Join the room, or accept an invitation. */ - fun join(viaServers: List = emptyList(), callback: MatrixCallback): Cancelable + fun join(reason: String?, viaServers: List = emptyList(), callback: MatrixCallback): Cancelable /** * Leave the room, or reject an invitation. */ - fun leave(callback: MatrixCallback): Cancelable + fun leave(reason: String?, callback: MatrixCallback): Cancelable } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomDirectoryService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomDirectoryService.kt index 4251a66304..711e2bd97c 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomDirectoryService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomDirectoryService.kt @@ -44,9 +44,9 @@ internal class DefaultRoomDirectoryService @Inject constructor(private val getPu .executeBy(taskExecutor) } - override fun joinRoom(roomId: String, callback: MatrixCallback): Cancelable { + override fun joinRoom(roomId: String, reason: String?, callback: MatrixCallback): Cancelable { return joinRoomTask - .configureWith(JoinRoomTask.Params(roomId)) { + .configureWith(JoinRoomTask.Params(roomId, reason)) { this.callback = callback } .executeBy(taskExecutor) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomService.kt index be2a588510..22caf76eaf 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomService.kt @@ -96,9 +96,9 @@ internal class DefaultRoomService @Inject constructor(private val monarchy: Mona .executeBy(taskExecutor) } - override fun joinRoom(roomId: String, viaServers: List, callback: MatrixCallback): Cancelable { + override fun joinRoom(roomId: String, reason: String?, viaServers: List, callback: MatrixCallback): Cancelable { return joinRoomTask - .configureWith(JoinRoomTask.Params(roomId, viaServers)) { + .configureWith(JoinRoomTask.Params(roomId, reason, viaServers)) { this.callback = callback } .executeBy(taskExecutor) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomAPI.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomAPI.kt index 797dbed31c..40164d1697 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomAPI.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomAPI.kt @@ -217,7 +217,7 @@ internal interface RoomAPI { @POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/join") fun join(@Path("roomId") roomId: String, @Query("server_name") viaServers: List, - @Body params: Map): Call + @Body params: Map): Call /** * Leave the given room. @@ -227,7 +227,7 @@ internal interface RoomAPI { */ @POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/leave") fun leave(@Path("roomId") roomId: String, - @Body params: Map): Call + @Body params: Map): Call /** * Strips all information out of an event which isn't critical to the integrity of the server-side representation of the room. diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/DefaultMembershipService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/DefaultMembershipService.kt index 3490fed30f..00c1c2c4ca 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/DefaultMembershipService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/DefaultMembershipService.kt @@ -83,8 +83,8 @@ internal class DefaultMembershipService @AssistedInject constructor(@Assisted pr return result } - override fun invite(userId: String, callback: MatrixCallback): Cancelable { - val params = InviteTask.Params(roomId, userId) + override fun invite(userId: String, reason: String?, callback: MatrixCallback): Cancelable { + val params = InviteTask.Params(roomId, userId, reason) return inviteTask .configureWith(params) { this.callback = callback @@ -92,8 +92,8 @@ internal class DefaultMembershipService @AssistedInject constructor(@Assisted pr .executeBy(taskExecutor) } - override fun join(viaServers: List, callback: MatrixCallback): Cancelable { - val params = JoinRoomTask.Params(roomId, viaServers) + override fun join(reason: String?, viaServers: List, callback: MatrixCallback): Cancelable { + val params = JoinRoomTask.Params(roomId, reason, viaServers) return joinTask .configureWith(params) { this.callback = callback @@ -101,8 +101,8 @@ internal class DefaultMembershipService @AssistedInject constructor(@Assisted pr .executeBy(taskExecutor) } - override fun leave(callback: MatrixCallback): Cancelable { - val params = LeaveRoomTask.Params(roomId) + override fun leave(reason: String?, callback: MatrixCallback): Cancelable { + val params = LeaveRoomTask.Params(roomId, reason) return leaveRoomTask .configureWith(params) { this.callback = callback diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/joining/InviteBody.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/joining/InviteBody.kt index 4529a17ab8..2d72197198 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/joining/InviteBody.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/joining/InviteBody.kt @@ -21,5 +21,6 @@ import com.squareup.moshi.JsonClass @JsonClass(generateAdapter = true) data class InviteBody( - @Json(name = "user_id") val userId: String + @Json(name = "user_id") val userId: String, + @Json(name = "reason") val reason: String? ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/joining/InviteTask.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/joining/InviteTask.kt index a41e8d3ca3..6bc453a0f3 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/joining/InviteTask.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/joining/InviteTask.kt @@ -24,7 +24,8 @@ import javax.inject.Inject internal interface InviteTask : Task { data class Params( val roomId: String, - val userId: String + val userId: String, + val reason: String? ) } @@ -32,7 +33,7 @@ internal class DefaultInviteTask @Inject constructor(private val roomAPI: RoomAP override suspend fun execute(params: InviteTask.Params) { return executeRequest { - val body = InviteBody(params.userId) + val body = InviteBody(params.userId, params.reason) apiCall = roomAPI.invite(params.roomId, body) } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/joining/JoinRoomTask.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/joining/JoinRoomTask.kt index 2555d80209..7304c09d57 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/joining/JoinRoomTask.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/joining/JoinRoomTask.kt @@ -32,6 +32,7 @@ import javax.inject.Inject internal interface JoinRoomTask : Task { data class Params( val roomId: String, + val reason: String?, val viaServers: List = emptyList() ) } @@ -43,7 +44,7 @@ internal class DefaultJoinRoomTask @Inject constructor(private val roomAPI: Room override suspend fun execute(params: JoinRoomTask.Params) { executeRequest { - apiCall = roomAPI.join(params.roomId, params.viaServers, HashMap()) + apiCall = roomAPI.join(params.roomId, params.viaServers, mapOf("reason" to params.reason)) } val roomId = params.roomId // Wait for room to come back from the sync (but it can maybe be in the DB is the sync response is received before) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/leaving/LeaveRoomTask.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/leaving/LeaveRoomTask.kt index be9a421e95..01198c47de 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/leaving/LeaveRoomTask.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/leaving/LeaveRoomTask.kt @@ -23,7 +23,8 @@ import javax.inject.Inject internal interface LeaveRoomTask : Task { data class Params( - val roomId: String + val roomId: String, + val reason: String? ) } @@ -31,7 +32,7 @@ internal class DefaultLeaveRoomTask @Inject constructor(private val roomAPI: Roo override suspend fun execute(params: LeaveRoomTask.Params) { return executeRequest { - apiCall = roomAPI.leave(params.roomId, HashMap()) + apiCall = roomAPI.leave(params.roomId, mapOf("reason" to params.reason)) } } } diff --git a/vector/src/main/java/im/vector/riotx/features/command/Command.kt b/vector/src/main/java/im/vector/riotx/features/command/Command.kt index 7d745b925b..9b3ecb3be5 100644 --- a/vector/src/main/java/im/vector/riotx/features/command/Command.kt +++ b/vector/src/main/java/im/vector/riotx/features/command/Command.kt @@ -27,12 +27,12 @@ import im.vector.riotx.R enum class Command(val command: String, val parameters: String, @StringRes val description: Int) { EMOTE("/me", "", R.string.command_description_emote), BAN_USER("/ban", " [reason]", R.string.command_description_ban_user), - UNBAN_USER("/unban", "", R.string.command_description_unban_user), + UNBAN_USER("/unban", " [reason]", R.string.command_description_unban_user), SET_USER_POWER_LEVEL("/op", " []", R.string.command_description_op_user), RESET_USER_POWER_LEVEL("/deop", "", R.string.command_description_deop_user), - INVITE("/invite", "", R.string.command_description_invite_user), - JOIN_ROOM("/join", "", R.string.command_description_join_room), - PART("/part", "", R.string.command_description_part_room), + INVITE("/invite", " [reason]", R.string.command_description_invite_user), + JOIN_ROOM("/join", " [reason]", R.string.command_description_join_room), + PART("/part", " [reason]", R.string.command_description_part_room), TOPIC("/topic", "", R.string.command_description_topic), KICK_USER("/kick", " [reason]", R.string.command_description_kick_user), CHANGE_DISPLAY_NAME("/nick", "", R.string.command_description_nick), diff --git a/vector/src/main/java/im/vector/riotx/features/command/CommandParser.kt b/vector/src/main/java/im/vector/riotx/features/command/CommandParser.kt index bc451f8e84..bdcaa4d9b8 100644 --- a/vector/src/main/java/im/vector/riotx/features/command/CommandParser.kt +++ b/vector/src/main/java/im/vector/riotx/features/command/CommandParser.kt @@ -81,29 +81,52 @@ object CommandParser { ParsedCommand.SendEmote(message) } Command.JOIN_ROOM.command -> { - val roomAlias = textMessage.substring(Command.JOIN_ROOM.command.length).trim() + if (messageParts.size >= 2) { + val roomAlias = messageParts[1] - if (roomAlias.isNotEmpty()) { - ParsedCommand.JoinRoom(roomAlias) + if (roomAlias.isNotEmpty()) { + ParsedCommand.JoinRoom( + roomAlias, + textMessage.substring(Command.JOIN_ROOM.command.length + 1 + roomAlias.length) + .trim() + .takeIf { it.isNotBlank() } + ) + } else { + ParsedCommand.ErrorSyntax(Command.JOIN_ROOM) + } } else { ParsedCommand.ErrorSyntax(Command.JOIN_ROOM) } } Command.PART.command -> { - val roomAlias = textMessage.substring(Command.PART.command.length).trim() + if (messageParts.size >= 2) { + val roomAlias = messageParts[1] - if (roomAlias.isNotEmpty()) { - ParsedCommand.PartRoom(roomAlias) + if (roomAlias.isNotEmpty()) { + ParsedCommand.PartRoom( + roomAlias, + textMessage.substring(Command.PART.command.length + 1 + roomAlias.length) + .trim() + .takeIf { it.isNotBlank() } + ) + } else { + ParsedCommand.ErrorSyntax(Command.PART) + } } else { ParsedCommand.ErrorSyntax(Command.PART) } } Command.INVITE.command -> { - if (messageParts.size == 2) { + if (messageParts.size >= 2) { val userId = messageParts[1] if (MatrixPatterns.isUserId(userId)) { - ParsedCommand.Invite(userId) + ParsedCommand.Invite( + userId, + textMessage.substring(Command.INVITE.command.length + 1 + userId.length) + .trim() + .takeIf { it.isNotBlank() } + ) } else { ParsedCommand.ErrorSyntax(Command.INVITE) } @@ -114,12 +137,14 @@ object CommandParser { Command.KICK_USER.command -> { if (messageParts.size >= 2) { val userId = messageParts[1] - if (MatrixPatterns.isUserId(userId)) { - val reason = textMessage.substring(Command.KICK_USER.command.length - + 1 - + userId.length).trim() - ParsedCommand.KickUser(userId, reason) + if (MatrixPatterns.isUserId(userId)) { + ParsedCommand.KickUser( + userId, + textMessage.substring(Command.KICK_USER.command.length + 1 + userId.length) + .trim() + .takeIf { it.isNotBlank() } + ) } else { ParsedCommand.ErrorSyntax(Command.KICK_USER) } @@ -130,12 +155,14 @@ object CommandParser { Command.BAN_USER.command -> { if (messageParts.size >= 2) { val userId = messageParts[1] - if (MatrixPatterns.isUserId(userId)) { - val reason = textMessage.substring(Command.BAN_USER.command.length - + 1 - + userId.length).trim() - ParsedCommand.BanUser(userId, reason) + if (MatrixPatterns.isUserId(userId)) { + ParsedCommand.BanUser( + userId, + textMessage.substring(Command.BAN_USER.command.length + 1 + userId.length) + .trim() + .takeIf { it.isNotBlank() } + ) } else { ParsedCommand.ErrorSyntax(Command.BAN_USER) } @@ -144,11 +171,16 @@ object CommandParser { } } Command.UNBAN_USER.command -> { - if (messageParts.size == 2) { + if (messageParts.size >= 2) { val userId = messageParts[1] if (MatrixPatterns.isUserId(userId)) { - ParsedCommand.UnbanUser(userId) + ParsedCommand.UnbanUser( + userId, + textMessage.substring(Command.UNBAN_USER.command.length + 1 + userId.length) + .trim() + .takeIf { it.isNotBlank() } + ) } else { ParsedCommand.ErrorSyntax(Command.UNBAN_USER) } diff --git a/vector/src/main/java/im/vector/riotx/features/command/ParsedCommand.kt b/vector/src/main/java/im/vector/riotx/features/command/ParsedCommand.kt index 89438c8a9d..dd7c0c7e86 100644 --- a/vector/src/main/java/im/vector/riotx/features/command/ParsedCommand.kt +++ b/vector/src/main/java/im/vector/riotx/features/command/ParsedCommand.kt @@ -34,14 +34,14 @@ sealed class ParsedCommand { // Valid commands: class SendEmote(val message: CharSequence) : ParsedCommand() - class BanUser(val userId: String, val reason: String) : ParsedCommand() - class UnbanUser(val userId: String) : ParsedCommand() + class BanUser(val userId: String, val reason: String?) : ParsedCommand() + class UnbanUser(val userId: String, val reason: String?) : ParsedCommand() class SetUserPowerLevel(val userId: String, val powerLevel: Int) : ParsedCommand() - class Invite(val userId: String) : ParsedCommand() - class JoinRoom(val roomAlias: String) : ParsedCommand() - class PartRoom(val roomAlias: String) : ParsedCommand() + class Invite(val userId: String, val reason: String?) : ParsedCommand() + class JoinRoom(val roomAlias: String, val reason: String?) : ParsedCommand() + class PartRoom(val roomAlias: String, val reason: String?) : ParsedCommand() class ChangeTopic(val topic: String) : ParsedCommand() - class KickUser(val userId: String, val reason: String) : ParsedCommand() + class KickUser(val userId: String, val reason: String?) : ParsedCommand() class ChangeDisplayName(val displayName: String) : ParsedCommand() class SetMarkdown(val enable: Boolean) : ParsedCommand() object ClearScalarToken : ParsedCommand() diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt index d0bff31f79..abdcc46f6a 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt @@ -266,7 +266,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro } } session.rx() - .joinRoom(roomId, viaServer) + .joinRoom(roomId, null, viaServer) .map { roomId } .execute { copy(tombstoneEventHandling = it) @@ -487,7 +487,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro private fun handleInviteSlashCommand(invite: ParsedCommand.Invite) { _sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandHandled()) - room.invite(invite.userId, object : MatrixCallback { + room.invite(invite.userId, invite.reason, object : MatrixCallback { override fun onSuccess(data: Unit) { _sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandResultOk) } @@ -553,11 +553,11 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro } private fun handleRejectInvite() { - room.leave(object : MatrixCallback {}) + room.leave(null, object : MatrixCallback {}) } private fun handleAcceptInvite() { - room.join(callback = object : MatrixCallback {}) + room.join(null, callback = object : MatrixCallback {}) } private fun handleEditAction(action: RoomDetailAction.EnterEditMode) { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListViewModel.kt index e5924d9f2a..8e9e76099d 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListViewModel.kt @@ -123,7 +123,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState, ) } - session.getRoom(roomId)?.join(emptyList(), object : MatrixCallback { + session.getRoom(roomId)?.join(null, emptyList(), object : MatrixCallback { override fun onSuccess(data: Unit) { // We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data. // Instead, we wait for the room to be joined @@ -158,7 +158,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState, ) } - session.getRoom(roomId)?.leave(object : MatrixCallback { + session.getRoom(roomId)?.leave(null, object : MatrixCallback { override fun onSuccess(data: Unit) { // We do not update the rejectingRoomsIds here, because, the room is not rejected yet regarding the sync data. // Instead, we wait for the room to be rejected @@ -197,7 +197,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState, } private fun handleLeaveRoom(action: RoomListAction.LeaveRoom) { - session.getRoom(action.roomId)?.leave(object : MatrixCallback { + session.getRoom(action.roomId)?.leave(null, object : MatrixCallback { override fun onFailure(failure: Throwable) { _viewEvents.post(RoomListViewEvents.Failure(failure)) } diff --git a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationBroadcastReceiver.kt b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationBroadcastReceiver.kt index 63cd1c5ce6..447137d263 100644 --- a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationBroadcastReceiver.kt +++ b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationBroadcastReceiver.kt @@ -74,14 +74,14 @@ class NotificationBroadcastReceiver : BroadcastReceiver() { private fun handleJoinRoom(roomId: String) { activeSessionHolder.getSafeActiveSession()?.let { session -> session.getRoom(roomId) - ?.join(emptyList(), object : MatrixCallback {}) + ?.join(null, emptyList(), object : MatrixCallback {}) } } private fun handleRejectRoom(roomId: String) { activeSessionHolder.getSafeActiveSession()?.let { session -> session.getRoom(roomId) - ?.leave(object : MatrixCallback {}) + ?.leave(null, object : MatrixCallback {}) } } diff --git a/vector/src/main/java/im/vector/riotx/features/roomdirectory/RoomDirectoryViewModel.kt b/vector/src/main/java/im/vector/riotx/features/roomdirectory/RoomDirectoryViewModel.kt index 685e1aa282..3f8b6883ab 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomdirectory/RoomDirectoryViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomdirectory/RoomDirectoryViewModel.kt @@ -214,7 +214,7 @@ class RoomDirectoryViewModel @AssistedInject constructor(@Assisted initialState: ) } - session.joinRoom(action.roomId, emptyList(), object : MatrixCallback { + session.joinRoom(action.roomId, null, emptyList(), object : MatrixCallback { override fun onSuccess(data: Unit) { // We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data. // Instead, we wait for the room to be joined diff --git a/vector/src/main/java/im/vector/riotx/features/roomdirectory/roompreview/RoomPreviewViewModel.kt b/vector/src/main/java/im/vector/riotx/features/roomdirectory/roompreview/RoomPreviewViewModel.kt index 9ffb64556f..42659b2b20 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomdirectory/roompreview/RoomPreviewViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomdirectory/roompreview/RoomPreviewViewModel.kt @@ -97,7 +97,7 @@ class RoomPreviewViewModel @AssistedInject constructor(@Assisted initialState: R ) } - session.joinRoom(state.roomId, emptyList(), object : MatrixCallback { + session.joinRoom(state.roomId, null, emptyList(), object : MatrixCallback { override fun onSuccess(data: Unit) { // We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data. // Instead, we wait for the room to be joined