From 94a2c04398bacf3fded7b29cba151cbb75b528b6 Mon Sep 17 00:00:00 2001 From: exinglang Date: Tue, 28 Jul 2026 22:25:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A8=E9=80=81):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=B0=8F=E7=B1=B3=E6=B5=8B=E8=AF=95=E6=8E=A8=E9=80=81=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/config.py | 1 + app/integrations/vendor_push.py | 1 + tests/test_device_push.py | 1 + 3 files changed, 3 insertions(+) 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