From 3abacb8a48ae9d8d2998e2a5e39e386a00a03c6b Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 31 Mar 2026 14:27:59 -0500 Subject: [PATCH] 's' --- app/routers/nomadvip.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/routers/nomadvip.py b/app/routers/nomadvip.py index 5c2f83b..759d767 100644 --- a/app/routers/nomadvip.py +++ b/app/routers/nomadvip.py @@ -57,6 +57,11 @@ def _cache_set(key: str, value: dict, ttl: int = _VIP_CACHE_TTL_SECONDS): _vip_check_cache[key] = (time.time() + ttl, value) +def _is_legacy_user_id(uid: str) -> bool: + uid = (uid or "").strip() + return uid.startswith("user") and uid[4:].isdigit() + + def _record_get(obj, key: str, default=None): """兼容 PocketBase SDK Record 与 dict 取值。""" if obj is None: @@ -376,7 +381,9 @@ async def nomadvip_check_vip(user_id: str = ""): if not linked_user_id or not _uid_has_vip(pb, linked_user_id): logging.info("[payjsapi] check_vip miss user_id=%s vip=False", user_id) result = {"vip": False} - _cache_set(cache_key, result) + # 真实 userid 的关联会在绑定后很快建立,避免 false 缓存导致多次进入才生效 + if _is_legacy_user_id(user_id): + _cache_set(cache_key, result) return result email = _get_linked_email_for_user(pb, user_id)