Latest renaming
This commit is contained in:
parent
a456f4c6a5
commit
0f327fc75f
|
@ -43,8 +43,8 @@ internal class CreateRoomBodyBuilder @Inject constructor(
|
||||||
private val accessTokenProvider: AccessTokenProvider
|
private val accessTokenProvider: AccessTokenProvider
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun build(builder: CreateRoomParams): CreateRoomBody {
|
suspend fun build(params: CreateRoomParams): CreateRoomBody {
|
||||||
val invite3pids = builder.invite3pids
|
val invite3pids = params.invite3pids
|
||||||
.takeIf { it.isNotEmpty() }
|
.takeIf { it.isNotEmpty() }
|
||||||
.let {
|
.let {
|
||||||
// This can throw Exception if Identity server is not configured
|
// This can throw Exception if Identity server is not configured
|
||||||
|
@ -54,7 +54,7 @@ internal class CreateRoomBodyBuilder @Inject constructor(
|
||||||
?: throw IdentityServiceError.NoIdentityServerConfigured
|
?: throw IdentityServiceError.NoIdentityServerConfigured
|
||||||
val identityServerAccessToken = accessTokenProvider.getToken() ?: throw IdentityServiceError.NoIdentityServerConfigured
|
val identityServerAccessToken = accessTokenProvider.getToken() ?: throw IdentityServiceError.NoIdentityServerConfigured
|
||||||
|
|
||||||
builder.invite3pids.map {
|
params.invite3pids.map {
|
||||||
ThreePidInviteBody(
|
ThreePidInviteBody(
|
||||||
id_server = identityServerUrlWithoutProtocol,
|
id_server = identityServerUrlWithoutProtocol,
|
||||||
id_access_token = identityServerAccessToken,
|
id_access_token = identityServerAccessToken,
|
||||||
|
@ -65,28 +65,28 @@ internal class CreateRoomBodyBuilder @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
val initialStates = listOfNotNull(
|
val initialStates = listOfNotNull(
|
||||||
buildEncryptionWithAlgorithmEvent(builder),
|
buildEncryptionWithAlgorithmEvent(params),
|
||||||
buildHistoryVisibilityEvent(builder)
|
buildHistoryVisibilityEvent(params)
|
||||||
)
|
)
|
||||||
.takeIf { it.isNotEmpty() }
|
.takeIf { it.isNotEmpty() }
|
||||||
|
|
||||||
return CreateRoomBody(
|
return CreateRoomBody(
|
||||||
visibility = builder.visibility,
|
visibility = params.visibility,
|
||||||
roomAliasName = builder.roomAliasName,
|
roomAliasName = params.roomAliasName,
|
||||||
name = builder.name,
|
name = params.name,
|
||||||
topic = builder.topic,
|
topic = params.topic,
|
||||||
invitedUserIds = builder.invitedUserIds,
|
invitedUserIds = params.invitedUserIds,
|
||||||
invite3pids = invite3pids,
|
invite3pids = invite3pids,
|
||||||
creationContent = builder.creationContent,
|
creationContent = params.creationContent,
|
||||||
initialStates = initialStates,
|
initialStates = initialStates,
|
||||||
preset = builder.preset,
|
preset = params.preset,
|
||||||
isDirect = builder.isDirect,
|
isDirect = params.isDirect,
|
||||||
powerLevelContentOverride = builder.powerLevelContentOverride
|
powerLevelContentOverride = params.powerLevelContentOverride
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildHistoryVisibilityEvent(builder: CreateRoomParams): Event? {
|
private fun buildHistoryVisibilityEvent(params: CreateRoomParams): Event? {
|
||||||
return builder.historyVisibility
|
return params.historyVisibility
|
||||||
?.let {
|
?.let {
|
||||||
val contentMap = mapOf("history_visibility" to it)
|
val contentMap = mapOf("history_visibility" to it)
|
||||||
|
|
||||||
|
@ -100,13 +100,13 @@ internal class CreateRoomBodyBuilder @Inject constructor(
|
||||||
/**
|
/**
|
||||||
* Add the crypto algorithm to the room creation parameters.
|
* Add the crypto algorithm to the room creation parameters.
|
||||||
*/
|
*/
|
||||||
private suspend fun buildEncryptionWithAlgorithmEvent(builder: CreateRoomParams): Event? {
|
private suspend fun buildEncryptionWithAlgorithmEvent(params: CreateRoomParams): Event? {
|
||||||
if (builder.algorithm == null
|
if (params.algorithm == null
|
||||||
&& canEnableEncryption(builder)) {
|
&& canEnableEncryption(params)) {
|
||||||
// Enable the encryption
|
// Enable the encryption
|
||||||
builder.enableEncryption()
|
params.enableEncryption()
|
||||||
}
|
}
|
||||||
return builder.algorithm
|
return params.algorithm
|
||||||
?.let {
|
?.let {
|
||||||
if (it != MXCRYPTO_ALGORITHM_MEGOLM) {
|
if (it != MXCRYPTO_ALGORITHM_MEGOLM) {
|
||||||
throw InvalidParameterException("Unsupported algorithm: $it")
|
throw InvalidParameterException("Unsupported algorithm: $it")
|
||||||
|
@ -121,12 +121,12 @@ internal class CreateRoomBodyBuilder @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun canEnableEncryption(builder: CreateRoomParams): Boolean {
|
private suspend fun canEnableEncryption(params: CreateRoomParams): Boolean {
|
||||||
return (builder.enableEncryptionIfInvitedUsersSupportIt
|
return (params.enableEncryptionIfInvitedUsersSupportIt
|
||||||
&& crossSigningService.isCrossSigningVerified()
|
&& crossSigningService.isCrossSigningVerified()
|
||||||
&& builder.invite3pids.isEmpty())
|
&& params.invite3pids.isEmpty())
|
||||||
&& builder.invitedUserIds.isNotEmpty()
|
&& params.invitedUserIds.isNotEmpty()
|
||||||
&& builder.invitedUserIds.let { userIds ->
|
&& params.invitedUserIds.let { userIds ->
|
||||||
val keys = deviceListManager.downloadKeys(userIds, forceDownload = false)
|
val keys = deviceListManager.downloadKeys(userIds, forceDownload = false)
|
||||||
|
|
||||||
userIds.all { userId ->
|
userIds.all { userId ->
|
||||||
|
|
|
@ -53,10 +53,10 @@ internal class DefaultCreateRoomTask @Inject constructor(
|
||||||
) : CreateRoomTask {
|
) : CreateRoomTask {
|
||||||
|
|
||||||
override suspend fun execute(params: CreateRoomParams): String {
|
override suspend fun execute(params: CreateRoomParams): String {
|
||||||
val createRoomParams = createRoomBodyBuilder.build(params)
|
val createRoomBody = createRoomBodyBuilder.build(params)
|
||||||
|
|
||||||
val createRoomResponse = executeRequest<CreateRoomResponse>(eventBus) {
|
val createRoomResponse = executeRequest<CreateRoomResponse>(eventBus) {
|
||||||
apiCall = roomAPI.createRoom(createRoomParams)
|
apiCall = roomAPI.createRoom(createRoomBody)
|
||||||
}
|
}
|
||||||
val roomId = createRoomResponse.roomId
|
val roomId = createRoomResponse.roomId
|
||||||
// Wait for room to come back from the sync (but it can maybe be in the DB if the sync response is received before)
|
// Wait for room to come back from the sync (but it can maybe be in the DB if the sync response is received before)
|
||||||
|
|
Loading…
Reference in New Issue