diff --git a/selfprivacy_api/graphql/common_types/service.py b/selfprivacy_api/graphql/common_types/service.py index 367ef6a..fb6c972 100644 --- a/selfprivacy_api/graphql/common_types/service.py +++ b/selfprivacy_api/graphql/common_types/service.py @@ -175,6 +175,7 @@ class Service: is_movable: bool is_required: bool is_enabled: bool + is_installed: bool can_be_backed_up: bool backup_description: str status: ServiceStatusEnum @@ -232,6 +233,7 @@ def service_to_graphql_service(service: ServiceInterface) -> Service: is_movable=service.is_movable(), is_required=service.is_required(), is_enabled=service.is_enabled(), + is_installed=service.is_installed(), can_be_backed_up=service.can_be_backed_up(), backup_description=service.get_backup_description(), status=ServiceStatusEnum(service.get_status().value), diff --git a/selfprivacy_api/services/service.py b/selfprivacy_api/services/service.py index 007070c..114d76c 100644 --- a/selfprivacy_api/services/service.py +++ b/selfprivacy_api/services/service.py @@ -146,6 +146,16 @@ class Service(ABC): with ReadUserData() as user_data: return user_data.get("modules", {}).get(name, {}).get("enable", False) + @classmethod + def is_installed(cls) -> bool: + """ + `True` if the service is installed. + `False` if there is no module data in user data + """ + name = cls.get_id() + with ReadUserData() as user_data: + return user_data.get("modules", {}).get(name, {}) != {} + @staticmethod @abstractmethod def get_status() -> ServiceStatus: