diff --git a/android/app/src/main/java/com/echo/app/notification/NotificationRuleEngine.kt b/android/app/src/main/java/com/echo/app/notification/NotificationRuleEngine.kt index 389a761..f23c76a 100644 --- a/android/app/src/main/java/com/echo/app/notification/NotificationRuleEngine.kt +++ b/android/app/src/main/java/com/echo/app/notification/NotificationRuleEngine.kt @@ -200,7 +200,9 @@ object NotificationRuleEngine { private fun matchRule(raw: NotificationDb.RawNotification, text: String, rule: Rule): Boolean { if (!rule.enabled) return false val channel = raw.channel ?: "" - val channelHit = rule.channels.isEmpty() || rule.channels.any { channel.contains(it) } + // 频道命中:优先用通知来源/标题匹配,必要时回退到正文匹配(兼容 adb shell / 部分厂商改名) + val channelHit = + rule.channels.isEmpty() || rule.channels.any { channel.contains(it) || text.contains(it) } val keywordHit = rule.keywords.isEmpty() || rule.keywords.any { text.contains(it) } return channelHit && keywordHit } @@ -288,4 +290,3 @@ object NotificationRuleEngine { return rule.defaultMerchant ?: "Unknown" } } - diff --git a/src/services/notificationRuleService.js b/src/services/notificationRuleService.js index 7a73cd8..0ae46ad 100644 --- a/src/services/notificationRuleService.js +++ b/src/services/notificationRuleService.js @@ -249,7 +249,10 @@ const matchRule = (notification, rule) => { if (!rule || rule.enabled === false) return false const channel = notification?.channel || '' const text = notification?.text || '' - const channelHit = !rule.channels?.length || rule.channels.some((item) => channel.includes(item)) + // 频道命中:优先用通知标题/来源匹配,退而求其次用正文包含匹配(兼容 adb shell / 部分 ROM) + const channelHit = + !rule.channels?.length || + rule.channels.some((item) => channel.includes(item) || text.includes(item)) const keywordHit = !rule.keywords?.length || rule.keywords.some((word) => text.includes(word)) return channelHit && keywordHit }