fix(sms): auth sms_send 接入 SendResult(修 cooldown_sec 500)+ 记 provider/fallback

批次2 将 send_code 返回类型 int→SendResult 后,sms_send 仍把它整体塞进
SmsSendResponse.cooldown_sec:int → pydantic ValidationError → 500。改为取
send_result.cooldown_sec;成功侧 EVENT_SMS_SEND details 加 provider/fallback。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
guke
2026-07-30 16:36:45 +08:00
parent 60c8fece23
commit ca206bccb2
2 changed files with 28 additions and 2 deletions
+5 -2
View File
@@ -207,7 +207,8 @@ def sms_send(req: SmsSendRequest, request: Request, db: DbSession) -> SmsSendRes
check_rate_limits(request, subject=req.device_id, rules=send_rules)
try:
cooldown = send_code(req.phone)
send_result = send_code(req.phone)
cooldown = send_result.cooldown_sec
except SmsError as e:
risk_repo.record_behavior_event(
db,
@@ -238,7 +239,9 @@ def sms_send(req: SmsSendRequest, request: Request, db: DbSession) -> SmsSendRes
phone=req.phone,
client_ip=_client_ip(request),
outcome="success",
details={"mock": settings.SMS_MOCK},
details={"mock": settings.SMS_MOCK,
"provider": send_result.provider,
"fallback": send_result.fallback},
evaluate_rule=risk_repo.RULE_SMS_HOURLY,
)