diff --git a/core/controllers/ProfileController.py b/core/controllers/ProfileController.py index 52e8a5c..3cac8d7 100644 --- a/core/controllers/ProfileController.py +++ b/core/controllers/ProfileController.py @@ -143,7 +143,7 @@ class ProfileController: from core.controllers.ConnectionController import ConnectionController - if profile.subscription is not None: + if profile.has_subscription(): subscription = ConnectionController.with_preferred_connection(profile.subscription.billing_code, task=WebServiceApiService.get_subscription, connection_observer=connection_observer) @@ -175,39 +175,34 @@ class ProfileController: if system_state is not None and system_state.profile_id is profile.id: return ConnectionController.system_uses_wireguard_interface() - else: - return False + return False @staticmethod def get_invoice(profile: Union[SessionProfile, SystemProfile]): - if profile.subscription is None: + if profile.has_subscription(): + return WebServiceApiService.get_invoice(profile.subscription.billing_code) + else: return None - return WebServiceApiService.get_invoice(profile.subscription.billing_code) - @staticmethod def attach_proxy_configuration(profile: Union[SessionProfile, SystemProfile]): - if not profile.is_session_profile(): - return None + if profile.is_session_profile() and profile.has_subscription(): - if profile.subscription is None: - return None + proxy_configuration = WebServiceApiService.get_proxy_configuration(profile.subscription.billing_code) - proxy_configuration = WebServiceApiService.get_proxy_configuration(profile.subscription.billing_code) - - if proxy_configuration is not None: - profile.attach_proxy_configuration(proxy_configuration) + if proxy_configuration is not None: + profile.attach_proxy_configuration(proxy_configuration) @staticmethod def get_proxy_configuration(profile: Union[SessionProfile, SystemProfile]): - if not profile.is_session_profile(): + if profile.is_session_profile(): + return profile.get_proxy_configuration() + else: return None - profile.get_proxy_configuration() - @staticmethod def has_proxy_configuration(profile: Union[SessionProfile, SystemProfile]): profile.has_proxy_configuration() @@ -217,10 +212,10 @@ class ProfileController: from core.controllers.ConnectionController import ConnectionController - if profile.subscription is None: + if not profile.has_subscription(): raise MissingSubscriptionError() - if profile.location is None: + if not profile.has_location(): raise MissingLocationError() wireguard_keys = ProfileController.__generate_wireguard_keys()