multiply repos
This commit is contained in:
parent
d90c0f40f4
commit
3dcf947c68
14
main.py
14
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] "
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user