diff --git a/selfprivacy_api/services/bitwarden/__init__.py b/selfprivacy_api/services/bitwarden/__init__.py index 5d27569..6c44aeb 100644 --- a/selfprivacy_api/services/bitwarden/__init__.py +++ b/selfprivacy_api/services/bitwarden/__init__.py @@ -4,6 +4,8 @@ import base64 import subprocess from typing import Optional, List +from selfprivacy_api.utils import get_domain + from selfprivacy_api.utils.systemd import get_service_status from selfprivacy_api.services.service import Service, ServiceStatus from selfprivacy_api.services.bitwarden.icon import BITWARDEN_ICON @@ -36,6 +38,12 @@ class Bitwarden(Service): def get_user() -> str: return "vaultwarden" + @staticmethod + def get_url() -> Optional[str]: + """Return service url.""" + domain = get_domain() + return f"https://password.{domain}" + @staticmethod def is_movable() -> bool: return True diff --git a/selfprivacy_api/services/gitea/__init__.py b/selfprivacy_api/services/gitea/__init__.py index 3247040..7029b48 100644 --- a/selfprivacy_api/services/gitea/__init__.py +++ b/selfprivacy_api/services/gitea/__init__.py @@ -4,6 +4,8 @@ import base64 import subprocess from typing import Optional, List +from selfprivacy_api.utils import get_domain + from selfprivacy_api.utils.systemd import get_service_status from selfprivacy_api.services.service import Service, ServiceStatus from selfprivacy_api.services.gitea.icon import GITEA_ICON @@ -32,6 +34,12 @@ class Gitea(Service): """Read SVG icon from file and return it as base64 encoded string.""" return base64.b64encode(GITEA_ICON.encode("utf-8")).decode("utf-8") + @staticmethod + def get_url() -> Optional[str]: + """Return service url.""" + domain = get_domain() + return f"https://git.{domain}" + @staticmethod def is_movable() -> bool: return True diff --git a/selfprivacy_api/services/jitsimeet/__init__.py b/selfprivacy_api/services/jitsimeet/__init__.py index 074c546..05ef2f7 100644 --- a/selfprivacy_api/services/jitsimeet/__init__.py +++ b/selfprivacy_api/services/jitsimeet/__init__.py @@ -9,6 +9,7 @@ from selfprivacy_api.utils.systemd import ( get_service_status_from_several_units, ) from selfprivacy_api.services.service import Service, ServiceStatus +from selfprivacy_api.utils import get_domain from selfprivacy_api.utils.block_devices import BlockDevice from selfprivacy_api.services.jitsimeet.icon import JITSI_ICON @@ -36,6 +37,12 @@ class JitsiMeet(Service): """Read SVG icon from file and return it as base64 encoded string.""" return base64.b64encode(JITSI_ICON.encode("utf-8")).decode("utf-8") + @staticmethod + def get_url() -> Optional[str]: + """Return service url.""" + domain = get_domain() + return f"https://meet.{domain}" + @staticmethod def is_movable() -> bool: return False diff --git a/selfprivacy_api/services/nextcloud/__init__.py b/selfprivacy_api/services/nextcloud/__init__.py index eee9fa7..6aee771 100644 --- a/selfprivacy_api/services/nextcloud/__init__.py +++ b/selfprivacy_api/services/nextcloud/__init__.py @@ -4,6 +4,7 @@ import base64 import subprocess from typing import Optional, List +from selfprivacy_api.utils import get_domain from selfprivacy_api.jobs import Job, Jobs from selfprivacy_api.utils.systemd import get_service_status @@ -35,6 +36,12 @@ class Nextcloud(Service): """Read SVG icon from file and return it as base64 encoded string.""" return base64.b64encode(NEXTCLOUD_ICON.encode("utf-8")).decode("utf-8") + @staticmethod + def get_url() -> Optional[str]: + """Return service url.""" + domain = get_domain() + return f"https://cloud.{domain}" + @staticmethod def is_movable() -> bool: return True diff --git a/selfprivacy_api/services/pleroma/__init__.py b/selfprivacy_api/services/pleroma/__init__.py index 16ee70c..eebd925 100644 --- a/selfprivacy_api/services/pleroma/__init__.py +++ b/selfprivacy_api/services/pleroma/__init__.py @@ -4,6 +4,8 @@ import base64 import subprocess from typing import Optional, List +from selfprivacy_api.utils import get_domain + from selfprivacy_api.services.owned_path import OwnedPath from selfprivacy_api.utils.systemd import get_service_status from selfprivacy_api.services.service import Service, ServiceStatus @@ -30,6 +32,12 @@ class Pleroma(Service): def get_svg_icon() -> str: return base64.b64encode(PLEROMA_ICON.encode("utf-8")).decode("utf-8") + @staticmethod + def get_url() -> Optional[str]: + """Return service url.""" + domain = get_domain() + return f"https://social.{domain}" + @staticmethod def is_movable() -> bool: return True diff --git a/selfprivacy_api/services/roundcube/__init__.py b/selfprivacy_api/services/roundcube/__init__.py index 7572770..9a52c3a 100644 --- a/selfprivacy_api/services/roundcube/__init__.py +++ b/selfprivacy_api/services/roundcube/__init__.py @@ -9,6 +9,7 @@ from selfprivacy_api.utils.systemd import ( get_service_status_from_several_units, ) from selfprivacy_api.services.service import Service, ServiceStatus +from selfprivacy_api.utils import get_domain from selfprivacy_api.utils.block_devices import BlockDevice from selfprivacy_api.services.roundcube.icon import ROUNDCUBE_ICON @@ -36,6 +37,13 @@ class Roundcube(Service): """Read SVG icon from file and return it as base64 encoded string.""" return base64.b64encode(ROUNDCUBE_ICON.encode("utf-8")).decode("utf-8") + @staticmethod + def get_url() -> Optional[str]: + """Return service url.""" + domain = get_domain() + subdomain = get_subdomain() + return f"https://{subdomain}.{domain}" + @staticmethod def is_movable() -> bool: return False diff --git a/selfprivacy_api/services/service.py b/selfprivacy_api/services/service.py index ed55a0e..262d690 100644 --- a/selfprivacy_api/services/service.py +++ b/selfprivacy_api/services/service.py @@ -4,7 +4,6 @@ from abc import ABC, abstractmethod from typing import List, Optional from selfprivacy_api import utils -from selfprivacy_api.utils import get_domain from selfprivacy_api.utils import ReadUserData, WriteUserData from selfprivacy_api.utils.waitloop import wait_until_true from selfprivacy_api.utils.block_devices import BlockDevice, BlockDevices @@ -67,13 +66,13 @@ class Service(ABC): """ pass + @staticmethod + @abstractmethod def get_url() -> Optional[str]: """ The url of the service if it is accessible from the internet browser. """ - domain = get_domain() - subdomain = self.get_subdomain() - return f"https://{subdomain}.{domain}" + pass def get_subdomain() -> Optional[str]: """