fix(push): 修复小米推送 restricted_package_name 硬编码问题

从推送配置中读取 Android 包名,配置缺失时记录警告并跳过推送,
不再使用 com.example.app 占位值导致推送无法送达。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
这个提交包含在:
XuqmGroup 2026-05-06 08:22:57 +08:00
父节点 538022b5f0
当前提交 9cb352bb99

查看文件

@ -50,11 +50,16 @@ public class XiaomiPushProvider implements PushProvider {
log.warn("Xiaomi push not configured"); log.warn("Xiaomi push not configured");
return false; return false;
} }
String packageName = resolveConfig(appId, "packageName", "");
if (packageName.isBlank()) {
log.warn("Xiaomi push skipped: packageName not configured for appId={}", appId);
return false;
}
try { try {
String form = "registration_id=" + URLEncoder.encode(token, StandardCharsets.UTF_8) String form = "registration_id=" + URLEncoder.encode(token, StandardCharsets.UTF_8)
+ "&title=" + URLEncoder.encode(title, StandardCharsets.UTF_8) + "&title=" + URLEncoder.encode(title, StandardCharsets.UTF_8)
+ "&description=" + URLEncoder.encode(body, StandardCharsets.UTF_8) + "&description=" + URLEncoder.encode(body, StandardCharsets.UTF_8)
+ "&restricted_package_name=com.example.app" + "&restricted_package_name=" + URLEncoder.encode(packageName, StandardCharsets.UTF_8)
+ "&notify_type=1"; + "&notify_type=1";
if (options != null && options.channelId() != null && !options.channelId().isBlank()) { if (options != null && options.channelId() != null && !options.channelId().isBlank()) {
form += "&channel_id=" + URLEncoder.encode(options.channelId(), StandardCharsets.UTF_8); form += "&channel_id=" + URLEncoder.encode(options.channelId(), StandardCharsets.UTF_8);