# PATH: bot/integrations/auth.py from __future__ import annotations from typing import Any, Dict from bot.integrations.cf_worker2 import allow_user, disallow_user, is_allowed, stats_today async def get_stats() -> Dict[str, Any]: """ handlers.py expects: allowed_users, profiles, uploads_today Worker2 currently provides: uploads_today_total, active_users_today, errors_last20 So we map what we can safely. """ st = await stats_today() if not isinstance(st, dict) or not st.get("ok"): return {"ok": False, "allowed_users": 0, "profiles": 0, "uploads_today": 0} uploads_today = int(st.get("uploads_today_total", 0) or 0) # We don't have direct counts for allowed_users/profiles from this endpoint. # Keep them as 0, but include extra keys for visibility. return { "ok": True, "allowed_users": 0, "profiles": 0, "uploads_today": uploads_today, "active_users_today": int(st.get("active_users_today", 0) or 0), "errors_last20": st.get("errors_last20", []) or [], "day": st.get("day"), }