diff --git a/core/controllers/ConnectionController.py b/core/controllers/ConnectionController.py index 1c966fe..921b900 100644 --- a/core/controllers/ConnectionController.py +++ b/core/controllers/ConnectionController.py @@ -42,7 +42,7 @@ class ConnectionController: if profile.has_subscription(): - if profile.subscription.expires_at is None: + if not profile.subscription.has_been_activated(): ProfileController.activate_subscription(profile, connection_observer=connection_observer) proxy_configuration = ConnectionController.with_preferred_connection(profile.subscription.billing_code, task=WebServiceApiService.get_proxy_configuration, connection_observer=connection_observer) @@ -59,7 +59,7 @@ class ConnectionController: if profile.has_subscription(): - if profile.subscription.expires_at is None: + if not profile.subscription.has_been_activated(): ProfileController.activate_subscription(profile, connection_observer=connection_observer) wireguard_configuration = ConnectionController.with_preferred_connection(profile.location.code, profile.subscription.billing_code, task=WebServiceApiService.post_wireguard_session, connection_observer=connection_observer) diff --git a/core/controllers/ProfileController.py b/core/controllers/ProfileController.py index 9324679..7537a08 100644 --- a/core/controllers/ProfileController.py +++ b/core/controllers/ProfileController.py @@ -168,7 +168,9 @@ class ProfileController: if profile.is_system_profile(): - if SystemStateController.get() is not None: + system_state = SystemStateController.get() + + if system_state is not None and system_state.profile_id is profile.id: return ConnectionController.system_uses_wireguard_interface() else: diff --git a/core/models/Subscription.py b/core/models/Subscription.py index 801706c..1139d07 100644 --- a/core/models/Subscription.py +++ b/core/models/Subscription.py @@ -21,8 +21,11 @@ class Subscription: ) ) + def has_been_activated(self): + return self.expires_at is not None + def is_active(self): - return self.expires_at is not None and self.expires_at > datetime.now(timezone.utc) + return self.has_been_activated() and self.expires_at > datetime.now(timezone.utc) @staticmethod def from_iso_format(datetime_string: str):