feat: 优化规则匹配逻辑,支持通知标题和正文的频道匹配

This commit is contained in:
2025-12-03 17:56:02 +08:00
parent 94c1eac279
commit cf760d4001
2 changed files with 7 additions and 3 deletions

View File

@@ -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"
}
}