diff --git a/main.py b/main.py index aea1f07..9419979 100644 --- a/main.py +++ b/main.py @@ -42,7 +42,7 @@ TELEGRAM_ALLOWED_USERNAMES = { if v.strip() } GITEA_COUNT_REPOS = { - v.strip() + v.strip().lower() for v in os.getenv("GITEA_COUNT_REPOS", "").split(",") if v.strip() } @@ -517,6 +517,14 @@ def verify_gitea_signature(raw_body: bytes, signature_header: str | None) -> boo return hmac.compare_digest(digest, signature_value) +def should_process_repo(repo_full_name: str | None) -> bool: + if not repo_full_name: + return False + if not GITEA_COUNT_REPOS: + return True + return repo_full_name.strip().lower() in GITEA_COUNT_REPOS + + def choose_reviewer(candidates: list[RegisteredUser]) -> RegisteredUser: return random.choice(candidates) @@ -1152,6 +1160,10 @@ async def gitea_webhook( except json.JSONDecodeError as exc: log_error("gitea webhook invalid json", exc) raise HTTPException(status_code=400, detail="Некорректный JSON") from exc + repo_full_name = ((payload.get("repository") or {}).get("full_name") or "").strip() + if repo_full_name and not should_process_repo(repo_full_name): + log_info(f"[gitea] repo={repo_full_name} не входит в GITEA_COUNT_REPOS, событие пропущено.") + return {"ok": "ignored"} log_info(f"[gitea] event={x_gitea_event} action={payload.get('action')}") log_info( "[route] "