feat: Implement subscription-based premium features, payment processing, and enhanced dashboard components.

This commit is contained in:
2569718930@qq.com
2026-03-13 06:41:33 +08:00
parent f7b649bb0a
commit 54c4a26162
19 changed files with 427 additions and 90 deletions
+11 -7
View File
@@ -134,15 +134,11 @@ class SupabaseEntitlementService:
logger.warning(f"supabase auth user check failed: {exc}")
return None
def has_active_subscription(self, user_id: str) -> bool:
if not self.require_subscription:
return True
def _query_active_subscription(self, user_id: str) -> bool:
if not user_id:
return False
if not self.service_role_key:
logger.warning(
"POLYWEATHER_AUTH_REQUIRE_SUBSCRIPTION=true but SUPABASE_SERVICE_ROLE_KEY is missing",
)
logger.warning("SUPABASE_SERVICE_ROLE_KEY is missing")
return False
now_ts = time.time()
@@ -188,6 +184,14 @@ class SupabaseEntitlementService:
logger.warning(f"supabase subscription query error user_id={user_id}: {exc}")
return False
def has_active_subscription(
self,
user_id: str,
respect_requirement: bool = True,
) -> bool:
if respect_requirement and not self.require_subscription:
return True
return self._query_active_subscription(user_id)
SUPABASE_ENTITLEMENT = SupabaseEntitlementService()