Use Content models in CreateRoomBodyBuilder

This commit is contained in:
Florian Renaud 2022-08-08 17:22:16 +02:00 committed by Florian Renaud
parent a1152ff72c
commit 9eb6969456
1 changed files with 9 additions and 4 deletions

View File

@ -20,8 +20,13 @@ import org.matrix.android.sdk.api.crypto.MXCRYPTO_ALGORITHM_MEGOLM
import org.matrix.android.sdk.api.extensions.tryOrNull
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.content.EncryptionEventContent
import org.matrix.android.sdk.api.session.events.model.toContent
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
import org.matrix.android.sdk.api.session.identity.toMedium
import org.matrix.android.sdk.api.session.room.model.RoomAvatarContent
import org.matrix.android.sdk.api.session.room.model.RoomGuestAccessContent
import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibilityContent
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
import org.matrix.android.sdk.api.util.MimeTypes
import org.matrix.android.sdk.internal.crypto.DeviceListManager
@ -133,7 +138,7 @@ internal class CreateRoomBodyBuilder @Inject constructor(
Event(
type = EventType.STATE_ROOM_AVATAR,
stateKey = "",
content = mapOf("url" to response.contentUri)
content = RoomAvatarContent(response.contentUri).toContent()
)
}
}
@ -144,7 +149,7 @@ internal class CreateRoomBodyBuilder @Inject constructor(
Event(
type = EventType.STATE_ROOM_HISTORY_VISIBILITY,
stateKey = "",
content = mapOf("history_visibility" to it)
content = RoomHistoryVisibilityContent(it.value).toContent()
)
}
}
@ -155,7 +160,7 @@ internal class CreateRoomBodyBuilder @Inject constructor(
Event(
type = EventType.STATE_ROOM_GUEST_ACCESS,
stateKey = "",
content = mapOf("guest_access" to it.value)
content = RoomGuestAccessContent(it.value).toContent()
)
}
}
@ -177,7 +182,7 @@ internal class CreateRoomBodyBuilder @Inject constructor(
Event(
type = EventType.STATE_ROOM_ENCRYPTION,
stateKey = "",
content = mapOf("algorithm" to it)
content = EncryptionEventContent(it).toContent()
)
}
}