Skip to content
Snippets Groups Projects
Commit 00ddff5e authored by Taras's avatar Taras
Browse files

Update validate email ds

parent 25bc762b
No related branches found
No related tags found
No related merge requests found
package org.futo.circles.auth.feature.sign_up.validate_email package org.futo.circles.auth.feature.sign_up.validate_email
import org.futo.circles.auth.feature.sign_up.SignUpDataSource import org.futo.circles.auth.feature.uia.UIADataSource.Companion.REGISTRATION_EMAIL_REQUEST_TOKEN_TYPE
import org.futo.circles.auth.feature.sign_up.SignUpDataSource.Companion.REGISTRATION_EMAIL_REQUEST_TOKEN_TYPE import org.futo.circles.auth.feature.uia.UIADataSource.Companion.REGISTRATION_EMAIL_SUBMIT_TOKEN_TYPE
import org.futo.circles.auth.feature.sign_up.SignUpDataSource.Companion.REGISTRATION_EMAIL_SUBMIT_TOKEN_TYPE import org.futo.circles.auth.feature.uia.UIADataSource.Companion.TYPE_PARAM_KEY
import org.futo.circles.auth.feature.uia.UIADataSourceProvider
import org.futo.circles.core.extensions.Response import org.futo.circles.core.extensions.Response
import org.matrix.android.sdk.api.auth.registration.RegistrationResult import org.matrix.android.sdk.api.auth.registration.RegistrationResult
import org.matrix.android.sdk.api.auth.registration.Stage import org.matrix.android.sdk.api.auth.registration.Stage
import javax.inject.Inject import javax.inject.Inject
class ValidateEmailDataSource @Inject constructor( class ValidateEmailDataSource @Inject constructor() {
private val signUpDataSource: SignUpDataSource
) { private val uiaDataSource = UIADataSourceProvider.getDataSourceOrThrow()
suspend fun sendValidationCode( suspend fun sendValidationCode(
email: String, email: String,
subscribeToUpdates: Boolean subscribeToUpdates: Boolean
): Response<RegistrationResult> = signUpDataSource.performRegistrationStage( ): Response<RegistrationResult> = uiaDataSource.performUIAStage(
mapOf( mapOf(
TYPE_PARAM_KEY to REGISTRATION_EMAIL_REQUEST_TOKEN_TYPE, TYPE_PARAM_KEY to REGISTRATION_EMAIL_REQUEST_TOKEN_TYPE,
EMAIL_PARAM_KEY to email, EMAIL_PARAM_KEY to email,
...@@ -24,7 +25,7 @@ class ValidateEmailDataSource @Inject constructor( ...@@ -24,7 +25,7 @@ class ValidateEmailDataSource @Inject constructor(
) )
suspend fun validateEmail(code: String): Response<RegistrationResult> = suspend fun validateEmail(code: String): Response<RegistrationResult> =
signUpDataSource.performRegistrationStage( uiaDataSource.performUIAStage(
mapOf( mapOf(
TYPE_PARAM_KEY to REGISTRATION_EMAIL_SUBMIT_TOKEN_TYPE, TYPE_PARAM_KEY to REGISTRATION_EMAIL_SUBMIT_TOKEN_TYPE,
TOKEN_PARAM_KEY to code TOKEN_PARAM_KEY to code
...@@ -32,7 +33,7 @@ class ValidateEmailDataSource @Inject constructor( ...@@ -32,7 +33,7 @@ class ValidateEmailDataSource @Inject constructor(
) )
fun shouldShowSubscribeToEmail(): Boolean = fun shouldShowSubscribeToEmail(): Boolean =
(signUpDataSource.currentStage as? Stage.Other)?.params?.get(OFFER_LIST_SUBSCRIPTION_KEY) as? Boolean (uiaDataSource.currentStage as? Stage.Other)?.params?.get(OFFER_LIST_SUBSCRIPTION_KEY) as? Boolean
?: false ?: false
companion object { companion object {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment