fix(push): 完善厂商推送参数与消息通知 #199
Reference in New Issue
Block a user
Delete Branch "fix-mate20PageError"
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?
🤖 review-pr 深审结论
🔴 建议改后再合(置信度 0.9)— 打破一个既有 push 测试,且大量新行为零覆盖。
实跑(worktree 合并最新 main)
pytest tests/test_push_center.py→ 1 failed:test_huawei_auth_and_send_payload。base 上该测试 passed,本 PR 改成 fail(已基线对照,确为本 PR 引入)。问题
test_huawei_auth_and_send_payload— 测试断言click_action == {"type": 3},但本 PR 在带notificationId时改成{"type": 1, "intent": ...}。本 PR 的 commit「chore(tests): 取消推送测试文件改动」把本该同步更新的测试回退了,留下与新代码矛盾的断言 → CI 红。请更新该用例到新的 click_action 语义。send_data_event/_send_*_data/vivoforegroundShow+addBadge+10089 回退/_vivo_click_intent_uri/oppo 角标/huaweitarget_user_type/点击 type=1 全无测试。厂商集成本就难在生产验证,既打破旧测试又不补新测试,质量缺口明显。send_data_event对每条通知给 honor/huawei/xiaomi 各多发一次透传推送(vivo/oppo 安全跳过)。设计如此(前台铃铛刷新),但厂商配额/QPS 需知悉。正面:
send_data_event在每设备循环内、失败被VendorPushError兜住不破坏主投递;HUAWEI_PUSH_TARGET_USER_TYPE(Field ge=0 le=1) + .env.example 说明合理。(ruff UP037@config.py:493 是 base 既有,非本 PR。)⚠️ 合并级冲突(与 #198,必看):#198 把
_request_json/_request_form的vendor/operation改成必填;本 PR 新增的_send_honor_data/_send_huawei_data/_send_xiaomi_data+vivo 10089 回退没传这两参。git 能干净自动合并、无文本冲突,但实跑证实合并后调用_send_xiaomi_data抛TypeError: _request_form() missing 2 required keyword-only arguments: 'vendor' and 'operation',且这条路径每条 honor/huawei/xiaomi 通知都会走到。谁后合谁必须给这些新 data 调用补vendor=/operation=(并顺带补结构化日志)。只读深审 · worktree 合并最新 main · 已实跑
c1e8fa0ca9to7474c2bebc🤖 review-pr 二审结论(head
7474c2b)🟡 明显改善,但还差一个测试没改 → CI 仍红(置信度 0.9)。本轮把 #198 的日志改动并入了本分支 + 新增「补齐厂商请求日志参数」提交,实测如下。
✅ 上一轮问题已解决
TypeError已修:_send_honor_data/_send_huawei_data/_send_xiaomi_data与 vivo 10089 回退现在都带了vendor=/operation=(新 operation=send_data_event)。实证直接调用_send_xiaomi_data不再抛missing ... 'vendor' and 'operation'。pytest tests/test_push_center.py tests/test_device_push.py→ 34 passed。🔴 仍未解决(净新增 1 个失败)
test_push_center.py::test_huawei_auth_and_send_payload仍 fail。本轮更新了其它测试却漏改这一个:它仍断言click_action == {"type": 3},而代码在带notificationId时已正确改为{"type": 1, "intent": ...}。这是测试没跟着改、不是代码 bug —— 请把断言改成新语义(有 notificationId →type=1+intent;无 →type=3)。pytest -q→ 9 failed / 633 passed,其中 8 个是 base main 既有失败(compare_record / coupon_proxy / invite* / notification_events / withdraw_tiers,与本 PR 无关),本 PR 净新增仅这 1 个。🟡 遗留(非崩溃,建议一并处理)
_raw_log_summary(不脱敏),honor/huawei/vivo/oppo 的响应体带access_token/authToken。本轮新测试test_vendor_http_logs_..._raw_response...里assert "raw-access-token" in messages把这行为固化了。虽是短期、仅推送权限,但与「不暴露服务端鉴权凭据」目标不一致。建议 authenticate 类响应改走已能脱敏 accesstoken/authtoken 键的_log_summary。send_data_event对每条通知给 honor/huawei/xiaomi 各多发一次透传(vivo/oppo 安全跳过)。设计如此(前台铃铛),厂商配额/QPS 需知悉。一句话:把
test_huawei_auth_and_send_payload的断言更新到新 click_action 语义,CI 即绿;access_token 日志脱敏建议顺带修。只读二审 · worktree 合并最新 main · 已实跑(全量套件+TypeError 实证)