feat: track designer downloads and notifications

This commit is contained in:
2026-03-08 23:42:18 +08:00
parent 5ff85debdc
commit 147fc58409
9 changed files with 119 additions and 37 deletions

View File

@@ -0,0 +1,29 @@
import logging
import httpx
from app.core.config import settings
logger = logging.getLogger(__name__)
def send_wecom_text(content: str) -> bool:
text = str(content or "").strip()
webhook = str(getattr(settings, "WECOM_BOT_WEBHOOK", "") or "").strip()
if not text or not webhook:
return False
try:
response = httpx.post(
webhook,
json={"msgtype": "text", "text": {"content": text[:3500]}},
timeout=10.0,
)
response.raise_for_status()
data = response.json()
ok = int(data.get("errcode", -1)) == 0
if not ok:
logger.warning(f"WeCom bot send failed: {data}")
return ok
except Exception as e:
logger.warning(f"WeCom bot send exception: {e}")
return False