Revert "feat: rewrite get_url()"

This reverts commit f834c85401.
This commit is contained in:
Inex Code 2024-06-26 14:21:26 +03:00
parent f1cc84b8c8
commit 306b7f898d
7 changed files with 49 additions and 4 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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]:
"""