diff --git a/config.template.toml b/config.template.toml index 939b932..2846117 100644 --- a/config.template.toml +++ b/config.template.toml @@ -1,7 +1,8 @@ [SERVER] host = "localhost" +root_url = "" # optional key, used for changing the root url in automation if domain is not https://mystb.in port = 8181 -session_secret = "" # Run: import secrets; print(secrets.token_urlsafe(64)) +session_secret = "" # Run: import secrets; print(secrets.token_urlsafe(64)) maintenance = false [DATABASE] diff --git a/src/core/database.py b/src/core/database.py index 1d1fbb4..f2518b6 100644 --- a/src/core/database.py +++ b/src/core/database.py @@ -44,6 +44,7 @@ LOGGER = logging.getLogger(__name__) SCHEMA_FILE = pathlib.Path("schema.sql") +ROOT_URL = CONFIG["SERVER"].get("root_url", "https://mystb.in") class Database: @@ -119,7 +120,7 @@ async def _post_gist_of_tokens(self) -> None: for paste_id, tokens in current_tokens.items(): filename = str(datetime.datetime.now(datetime.UTC)) + "-tokens.txt" - json_payload["files"][filename] = {"content": f"https://mystb.in/{paste_id}:\n{tokens}"} + json_payload["files"][filename] = {"content": f"{ROOT_URL}/{paste_id}:\n{tokens}"} success = False diff --git a/src/types_/config.py b/src/types_/config.py index ce50254..e86cd96 100644 --- a/src/types_/config.py +++ b/src/types_/config.py @@ -25,6 +25,7 @@ class Server(TypedDict): host: str + root_url: NotRequired[str] port: int domain: str session_secret: str