Spaces:
Runtime error
Runtime error
File size: 1,111 Bytes
8cbb291 bf242bc 8cbb291 bf242bc 8cbb291 bf242bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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"),
} |