diff options
| author | Albin <albin@mullvad.net> | 2023-11-15 14:43:18 +0100 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2023-11-15 14:43:18 +0100 |
| commit | 3348ee8089ffcdc1305d0f44bab71f62def8082b (patch) | |
| tree | 8d89e5d760a6130c27ce7fe5a1d2be6eddeb182e | |
| parent | f630f1aff25ddde3f5da27ba88d33afe263b5c22 (diff) | |
| parent | 64f39005a49c1898cbad9e66e4bc197ff9727687 (diff) | |
| download | mullvadvpn-3348ee8089ffcdc1305d0f44bab71f62def8082b.tar.xz mullvadvpn-3348ee8089ffcdc1305d0f44bab71f62def8082b.zip | |
Merge branch 'account-expiry-time-not-updated-after-redeeming-voucher-droid-429'
2 files changed, 17 insertions, 2 deletions
diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt index fe7ddb75e9..c4a733d919 100644 --- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt +++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/ServiceEndpoint.kt @@ -49,7 +49,7 @@ class ServiceEndpoint( val locationInfoCache = LocationInfoCache(this) val relayListListener = RelayListListener(this) val splitTunneling = SplitTunneling(SplitTunnelingPersistence(context), this) - val voucherRedeemer = VoucherRedeemer(this) + val voucherRedeemer = VoucherRedeemer(this, accountCache) private val deviceRepositoryBackend = DaemonDeviceDataSource(this) diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VoucherRedeemer.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VoucherRedeemer.kt index a7003d6888..e7ecf5807d 100644 --- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VoucherRedeemer.kt +++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/VoucherRedeemer.kt @@ -6,10 +6,16 @@ import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.ClosedReceiveChannelException import kotlinx.coroutines.channels.actor import kotlinx.coroutines.channels.trySendBlocking +import net.mullvad.mullvadvpn.lib.common.util.parseAsDateTime import net.mullvad.mullvadvpn.lib.ipc.Event import net.mullvad.mullvadvpn.lib.ipc.Request +import net.mullvad.mullvadvpn.model.AccountExpiry +import net.mullvad.mullvadvpn.model.VoucherSubmissionResult -class VoucherRedeemer(private val endpoint: ServiceEndpoint) { +class VoucherRedeemer( + private val endpoint: ServiceEndpoint, + private val accountCache: AccountCache +) { private val daemon get() = endpoint.intermittentDaemon @@ -31,6 +37,15 @@ class VoucherRedeemer(private val endpoint: ServiceEndpoint) { for (voucher in channel) { val result = daemon.await().submitVoucher(voucher) + // Let AccountCache know about the new expiry + if (result is VoucherSubmissionResult.Ok) { + val newExpiry = result.submission.newExpiry.parseAsDateTime() + if (newExpiry != null) { + accountCache.onAccountExpiryChange.notify( + AccountExpiry.Available(newExpiry) + ) + } + } endpoint.sendEvent(Event.VoucherSubmissionResult(voucher, result)) } } catch (exception: ClosedReceiveChannelException) { |
