diff --git a/app/core/config.py b/app/core/config.py index e020307..4f2f5d4 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -104,6 +104,7 @@ class Settings(BaseSettings): XIAOMI_PUSH_APP_SECRET: str = "" XIAOMI_PUSH_SEND_ENDPOINT: str = "https://api.xmpush.xiaomi.com/v3/message/regid" + XIAOMI_PUSH_MODE: int = 1 # 0=正式推送,1=测试推送 XIAOMI_PUSH_CHANNEL_ID: str = "" XIAOMI_PUSH_TEMPLATE_ID: str = "" XIAOMI_PUSH_TEMPLATE_TITLE: str = "" diff --git a/app/integrations/vendor_push.py b/app/integrations/vendor_push.py index 54c0e0e..f16f69c 100644 --- a/app/integrations/vendor_push.py +++ b/app/integrations/vendor_push.py @@ -424,6 +424,7 @@ def _send_xiaomi(token: str, title: str, body: str, extras: dict[str, str]) -> d "payload": json.dumps(extras, ensure_ascii=False), "pass_through": "0", "notify_type": "-1", + "pushMode": settings.XIAOMI_PUSH_MODE, "time_to_live": str(settings.PUSH_TIME_TO_LIVE_SEC * 1000), } # 点击落地:带 notificationId 的消息中心推送 → notify_effect=2 + intent_uri,MiPush 直接打开 diff --git a/tests/test_device_push.py b/tests/test_device_push.py index a35ec24..038cf00 100644 --- a/tests/test_device_push.py +++ b/tests/test_device_push.py @@ -48,6 +48,7 @@ def test_xiaomi_accessibility_payload(monkeypatch) -> None: body = captured["data"] assert body["registration_id"] == "xm-regid" assert body["restricted_package_name"] == "com.jishisongfu.shaguabijia" + assert body["pushMode"] == 1 assert json.loads(body["payload"]) == {"type": "accessibility_disabled"} assert "extra.channel_id" not in body