feat(points): P2 step 1 - POINTS_ENABLED safety gate (default false) #1936
Reference in New Issue
Block a user
Delete Branch "feat/points-gate-config"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#1895 P2 第 1 步:积分系统配置安全闸门
按要求先补总开关,再逐个路由接入 @points_gate,确保 P2 阶段合入后对现有用户零影响。
改动
packages/config/base.pySharedSettings 新增points_enabled: bool = False(pydantic-settings 大小写不敏感,自动支持POINTS_ENABLED=true环境变量).env.example新增POINTS_ENABLED=false配置项及注释说明packages/middleware/points_gate.py新增模块级函数_points_gate_enabled()读取开关:@points_gate装饰器完全透传原函数,零开销零副作用,不读 user/db、不扣点、不抛 401/402test_config_base.py加 4 个用例:默认 false、环境变量 true、关闭时装饰器透传、开启时强制鉴权test_points_gate.py所有用例加 autouse fixturemonkeypatch.setattr(_points_gate_enabled, lambda: True),确保原有 10 个测试继续覆盖开启时的行为验证
后续 PR 计划(按你给的优先级):
🚀 预览环境已部署
🗑️ 预览环境已清理
PR #1936 已关闭或合并,对应的预览环境已被清理。
🗑️ 预览环境已清理
PR #1936 已关闭或合并,对应的预览环境已被清理。