fix(fudai): validator 内容检查正确尊重 disable 配置

当 config.json 中 fudai_disable_content_recognition=true 时,
跳过内容为空的检查。原实现在 except 块中丢失 disable_content
状态,导致配置生效时仍误判内容为空为验证失败。

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
CodexandClaude Sonnet 4.5 committed 2026-05-23 19:00:32 +08:00
1 parent d850af2c44
commit 8fd38dd30b
1 file changed
+19 -27
+19 -27
View File
@@ -54,37 +54,29 @@ def validate_fudai_detail(detail: Tuple, analyser: Any = None) -> Tuple[bool, st
# 检查1:内容不能为空(至少要有一些文字)
# 如果运行时显式禁用了内容识别,则跳过此检查(允许内容为空)
try:
disable_content = False
if analyser:
disable_content = False
if analyser:
try:
disable_content = bool(
getattr(analyser, "fudai_disable_content_recognition", False)
)
# 如果 analyser 未设置该属性,再尝试从 config.json 读取全局配置
if not disable_content:
try:
cfg_path = path_config.get_config_path()
if cfg_path and os.path.exists(cfg_path):
with open(cfg_path, "r", encoding="utf-8") as f:
cfg = json.load(f)
disable_content = bool(
cfg.get("fudai_disable_content_recognition", False)
)
except Exception:
pass
if not disable_content:
if not content or len(content.strip()) < 2:
# 内容为空但价值和倒计时都合理时,不应判定失败(部分福袋确实无文字内容)
if prize_value_yuan > 0 and countdown_end is not None and countdown_end > 0:
pass
else:
return False, "content_empty_or_too_short"
except Exception:
except Exception:
pass
if not disable_content:
try:
cfg_path = path_config.get_config_path()
if cfg_path and os.path.exists(cfg_path):
with open(cfg_path, "r", encoding="utf-8") as f:
cfg = json.load(f)
disable_content = bool(
cfg.get("fudai_disable_content_recognition", False)
)
except Exception:
pass
if not disable_content:
if not content or len(content.strip()) < 2:
if prize_value_yuan > 0 and countdown_end is not None and countdown_end > 0:
pass
else:
return False, "content_empty_or_too_short"
return False, "content_empty_or_too_short"
# 检查2:价值应该大于0(福袋至少应该有价值)
if prize_value_yuan <= 0: