Skip to content
Snippets Groups Projects
Commit 6d1593fc authored by Adrien Béraud's avatar Adrien Béraud
Browse files

linkdevice: set proxy settings when importing

Change-Id: I25d51a9574a2fee05507065b392f18714eefbccb
parent a23c5f2a
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ import net.jami.model.AccountConfig
import net.jami.model.ConfigKey
import net.jami.services.AccountService
import net.jami.services.AccountService.AuthError
import net.jami.services.DeviceRuntimeService
import net.jami.utils.Log
import javax.inject.Inject
import javax.inject.Named
......@@ -54,7 +55,8 @@ sealed class AddDeviceImportState {
@HiltViewModel
class ImportSideViewModel @Inject constructor(
private val accountService: AccountService,
@param:Named("UiScheduler") private val mUiScheduler: Scheduler
@param:Named("UiScheduler") private val mUiScheduler: Scheduler,
private val mDeviceService: DeviceRuntimeService,
) : AuthStateListener, ViewModel() {
// Expose screen UI state
......@@ -71,6 +73,7 @@ class ImportSideViewModel @Inject constructor(
accountService.getAccountTemplate(AccountConfig.ACCOUNT_TYPE_JAMI)
.flatMapObservable { accountDetails: HashMap<String, String> ->
accountDetails[ConfigKey.ARCHIVE_URL.key] = "jami-auth"
setProxyDetails(accountDetails)
accountService.addAccount(accountDetails)
}
.firstOrError()
......@@ -83,6 +86,15 @@ class ImportSideViewModel @Inject constructor(
.apply { compositeDisposable.add(this) }
}
private fun setProxyDetails(details: MutableMap<String, String>) {
details[ConfigKey.PROXY_ENABLED.key] = AccountConfig.TRUE_STR
val pushToken = mDeviceService.pushToken
if (pushToken.isNotEmpty()) {
details[ConfigKey.PROXY_PUSH_TOKEN.key] = pushToken
details[ConfigKey.PROXY_PUSH_PLATFORM.key] = mDeviceService.pushPlatform
}
}
fun onAuthentication(password: String = "") {
_tempAccount?.accountId?.apply {
accountService.provideAccountAuthentication(this, password)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment