From 5b470546fd478a322b121ec60a1f4c05d4d61ff6 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 30 Mar 2019 22:59:57 -0400 Subject: Filter notif titles as well from settings, resolves #1333 --- .../com/pitchedapps/frost/services/FrostNotifications.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt index f66f77e2..54a9f8ae 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt @@ -126,9 +126,19 @@ enum class NotificationType( L.v { "$name notification data not found" } return -1 } + + /** + * Checks that the text doesn't contain any blacklisted keywords + */ + fun validText(text: String?): Boolean { + val t = text ?: return true + return Prefs.notificationKeywords.none { + t.contains(it, true) + } + } + val notifContents = response.data.getUnreadNotifications(data).filter { notif -> - val text = notif.text - Prefs.notificationKeywords.none { text.contains(it, true) } + validText(notif.title) && validText(notif.text) } if (notifContents.isEmpty()) return 0 val userId = data.id -- cgit v1.2.3