refactor: remove GitHub webhook support

This commit is contained in:
Azimkin
2026-09-14 13:39:41 +02:00
parent 3f0cce6732
commit 3a8c198caa
7 changed files with 1 additions and 682 deletions

View File

@@ -33,14 +33,6 @@ class AccountConfig:
hide_password: bool = False
@dataclass(slots=True)
class GitHubWebhookConfig:
enabled: bool = False
host: str = "0.0.0.0"
port: int = 8080
secret: str | None = None
@dataclass(slots=True)
class ElevenLabsConfig:
api_key: str | None = None
@@ -85,7 +77,6 @@ class AppConfig:
api_hash: str | None
session_dir: Path
accounts: list[AccountConfig]
github_webhook: GitHubWebhookConfig = field(default_factory=GitHubWebhookConfig)
elevenlabs: ElevenLabsConfig = field(default_factory=ElevenLabsConfig)
ai: AiConfig = field(default_factory=AiConfig)
@@ -102,20 +93,6 @@ def _parse_int(value: Any, *, field_name: str) -> int:
raise ValueError(f"{field_name} must be an integer") from exc
def _parse_bool(value: Any, *, field_name: str) -> bool:
if isinstance(value, bool):
return value
if isinstance(value, str):
normalized = value.strip().lower()
if normalized in {"1", "true", "yes", "on"}:
return True
if normalized in {"0", "false", "no", "off"}:
return False
if isinstance(value, int):
return bool(value)
raise ValueError(f"{field_name} must be a boolean")
def _parse_float(value: Any, *, field_name: str) -> float:
try:
return float(value)
@@ -131,52 +108,6 @@ def _parse_mapping(value: Any, *, field_name: str) -> dict[str, Any]:
return value
def _parse_github_webhook_config(raw: Any) -> GitHubWebhookConfig:
raw_config = _parse_mapping(raw, field_name="github_webhook")
enabled = _parse_bool(
raw_config.get("enabled", False),
field_name="github_webhook.enabled",
)
host = str(raw_config.get("host", "0.0.0.0") or "0.0.0.0").strip()
if not host:
raise ValueError("github_webhook.host is required")
port = _parse_int(raw_config.get("port", 8080), field_name="github_webhook.port")
if port < 1 or port > 65535:
raise ValueError("github_webhook.port must be between 1 and 65535")
raw_secret = raw_config.get("secret")
secret = str(raw_secret).strip() if raw_secret is not None else None
secret = secret or None
if os.environ.get("GITHUB_WEBHOOK_ENABLED") is not None:
enabled = _parse_bool(
os.environ["GITHUB_WEBHOOK_ENABLED"],
field_name="GITHUB_WEBHOOK_ENABLED",
)
if os.environ.get("GITHUB_WEBHOOK_HOST") is not None:
host = os.environ["GITHUB_WEBHOOK_HOST"].strip()
if not host:
raise ValueError("GITHUB_WEBHOOK_HOST is required")
if os.environ.get("GITHUB_WEBHOOK_PORT") is not None:
port = _parse_int(os.environ["GITHUB_WEBHOOK_PORT"], field_name="GITHUB_WEBHOOK_PORT")
if port < 1 or port > 65535:
raise ValueError("GITHUB_WEBHOOK_PORT must be between 1 and 65535")
if os.environ.get("GITHUB_WEBHOOK_SECRET") is not None:
secret = os.environ["GITHUB_WEBHOOK_SECRET"].strip() or None
if enabled and not secret:
raise ValueError("github_webhook.secret is required when github_webhook.enabled is true")
return GitHubWebhookConfig(
enabled=enabled,
host=host,
port=port,
secret=secret,
)
def _parse_elevenlabs_config(raw: Any) -> ElevenLabsConfig:
raw_config = _parse_mapping(raw, field_name="elevenlabs")
@@ -461,7 +392,6 @@ def load_app_config(root: Path) -> AppConfig:
default_session_dir=session_dir,
)
github_webhook = _parse_github_webhook_config(raw.get("github_webhook"))
elevenlabs = _parse_elevenlabs_config(raw.get("elevenlabs"))
ai = _parse_ai_config(raw.get("ai"))
ai.prompt_dir = root / "prompts"
@@ -485,7 +415,6 @@ def load_app_config(root: Path) -> AppConfig:
api_hash=api_hash,
session_dir=session_dir,
accounts=accounts,
github_webhook=github_webhook,
elevenlabs=elevenlabs,
ai=ai,
)