first commit

This commit is contained in:
dekun
2026-08-01 10:33:19 +08:00
commit d9a34d4f20
72 changed files with 5499 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
"""通知相关 API(需鉴权)。"""
from __future__ import annotations
from fastapi import APIRouter, Depends
from apps.api.auth import require_auth
from packages.notify import wecom
router = APIRouter(prefix="/notify", tags=["notify"], dependencies=[Depends(require_auth)])
@router.get("/wecom/status")
def wecom_status() -> dict:
url = wecom.wecom_webhook_url()
masked = None
if url:
if len(url) > 24:
masked = url[:18] + "" + url[-6:]
else:
masked = "***"
return {
"enabled": wecom.wecom_enabled(),
"webhook_configured": bool(url),
"webhook_url_masked": masked,
"machine_name": wecom.wecom_machine_name(),
"alert_fail_threshold": wecom.alert_fail_threshold(),
}
@router.post("/wecom/test")
def wecom_test() -> dict:
ok, msg = wecom.notify_test()
return {"ok": ok, "message": msg}