Skip to content

Commit

Permalink
chore: allow customising a client name with a suffix [ACOL-144] (#2480)
Browse files Browse the repository at this point in the history
* chore: client flavor and build type

* detekt fix

* typo fix
  • Loading branch information
Garzas authored Feb 9, 2024
1 parent 98d2d4f commit c534b24
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ClientMapper(
deviceType = toDeviceTypeDTO(clientConfig.deviceType()),
type = param.clientType?.let { toClientTypeDTO(param.clientType) } ?: toClientTypeDTO(clientConfig.clientType()),
capabilities = param.capabilities?.let { capabilities -> capabilities.map { toClientCapabilityDTO(it) } },
model = param.model?.let { param.model } ?: clientConfig.deviceModelName(),
model = (param.model?.let { param.model } ?: clientConfig.deviceModelName()) + param.modelPostfix.orEmpty(),
preKeys = param.preKeys.map { preyKeyMapper.toPreKeyDTO(it) },
cookieLabel = param.cookieLabel,
secondFactorVerificationCode = param.secondFactorVerificationCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ data class RegisterClientParam(
val model: String?,
val cookieLabel: String?,
val secondFactorVerificationCode: String? = null,
val modelPostfix: String? = null
)

data class DeleteClientParam(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ interface RegisterClientUseCase {
val model: String? = null,
val preKeysToSend: Int = DEFAULT_PRE_KEYS_COUNT,
val secondFactorVerificationCode: String? = null,
val modelPostfix: String? = null
)

companion object {
Expand Down Expand Up @@ -135,7 +136,16 @@ class RegisterClientUseCaseImpl @OptIn(DelicateKaliumApi::class) internal constr
val verificationCode = registerClientParam.secondFactorVerificationCode ?: currentlyStoredVerificationCode()
sessionRepository.cookieLabel(selfUserId)
.flatMap { cookieLabel ->
generateProteusPreKeys(preKeysToSend, password, capabilities, clientType, model, cookieLabel, verificationCode)
generateProteusPreKeys(
preKeysToSend,
password,
capabilities,
clientType,
model,
cookieLabel,
verificationCode,
modelPostfix
)
}.fold({
RegisterClientResult.Failure.Generic(it)
}, { registerClientParam ->
Expand Down Expand Up @@ -209,6 +219,7 @@ class RegisterClientUseCaseImpl @OptIn(DelicateKaliumApi::class) internal constr
model: String? = null,
cookieLabel: String?,
secondFactorVerificationCode: String? = null,
modelPostfix: String?
) = withContext(dispatchers.io) {
preKeyRepository.generateNewPreKeys(FIRST_KEY_ID, preKeysToSend).flatMap { preKeys ->
preKeyRepository.generateNewLastResortKey().flatMap { lastKey ->
Expand All @@ -224,6 +235,7 @@ class RegisterClientUseCaseImpl @OptIn(DelicateKaliumApi::class) internal constr
clientType = clientType,
cookieLabel = cookieLabel,
secondFactorVerificationCode = secondFactorVerificationCode,
modelPostfix = modelPostfix
)
)
}
Expand Down

0 comments on commit c534b24

Please sign in to comment.