Files
life-echo/api/app/features/conversation/ws/quota_guard.py
2026-03-19 14:36:40 +08:00

11 lines
442 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""WebSocket 配额检查:通过注入 QuotaService不直接 import quota 内部函数。"""
from app.features.quota.service import QuotaService
async def check_ws_quota(
quota_service: QuotaService, user_id: str, subscription_type: str
) -> tuple[bool, str]:
"""检查用户是否还能发送消息。返回 (是否允许, 提示信息)。"""
return await quota_service.check_can_send_message(user_id, subscription_type)