diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/create/RoomFeaturePreset.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/create/RoomFeaturePreset.kt index 6487ad947f..3ed3e2d3a6 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/create/RoomFeaturePreset.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/create/RoomFeaturePreset.kt @@ -16,7 +16,6 @@ package org.matrix.android.sdk.api.session.room.model.create -import org.matrix.android.sdk.api.session.events.model.Event import org.matrix.android.sdk.api.session.events.model.EventType import org.matrix.android.sdk.api.session.events.model.toContent import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilities @@ -30,7 +29,7 @@ interface RoomFeaturePreset { fun updateRoomParams(params: CreateRoomParams) - fun setupInitialStates(): List? + fun setupInitialStates(): List? } class RestrictedRoomPreset(val homeServerCapabilities: HomeServerCapabilities, val restrictedList: List) : RoomFeaturePreset { @@ -41,9 +40,9 @@ class RestrictedRoomPreset(val homeServerCapabilities: HomeServerCapabilities, v params.roomVersion = homeServerCapabilities.versionOverrideForFeature(HomeServerCapabilities.ROOM_CAP_RESTRICTED) } - override fun setupInitialStates(): List? { + override fun setupInitialStates(): List { return listOf( - Event( + CreateRoomStateEvent( type = EventType.STATE_ROOM_JOIN_RULES, stateKey = "", content = RoomJoinRulesContent( diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomBodyBuilder.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomBodyBuilder.kt index faf68d538f..d62b21c3e8 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomBodyBuilder.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomBodyBuilder.kt @@ -78,7 +78,7 @@ internal class CreateRoomBodyBuilder @Inject constructor( buildAvatarEvent(params), buildGuestAccess(params) ) + - params.featurePreset?.setupInitialStates().orEmpty() + + buildFeaturePresetInitialStates(params) + buildCustomInitialStates(params) ) .takeIf { it.isNotEmpty() } @@ -99,6 +99,16 @@ internal class CreateRoomBodyBuilder @Inject constructor( ) } + private fun buildFeaturePresetInitialStates(params: CreateRoomParams): List { + return params.featurePreset?.setupInitialStates().orEmpty().map { + Event( + type = it.type, + stateKey = it.stateKey, + content = it.content + ) + } + } + private fun buildCustomInitialStates(params: CreateRoomParams): List { return params.initialStates.map { Event(