diff options
author | Allan Wang <me@allanwang.ca> | 2019-04-21 20:22:11 -0400 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-04-21 20:22:11 -0400 |
commit | bbafb7b65ce655c1fdda8badd3098d2a0e1f7f08 (patch) | |
tree | 354b0bb6f021af54d1e3586e3e9bda064ad4ef02 /app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt | |
parent | e5eb928feacba8d1c634ad8e5d85259ae161cabd (diff) | |
parent | f0f95295bdb2b853aa6262ec4bed2353ce326eee (diff) | |
download | frost-bbafb7b65ce655c1fdda8badd3098d2a0e1f7f08.tar.gz frost-bbafb7b65ce655c1fdda8badd3098d2a0e1f7f08.tar.bz2 frost-bbafb7b65ce655c1fdda8badd3098d2a0e1f7f08.zip |
Merge dev
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt | 19 |
1 files changed, 12 insertions, 7 deletions
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 631912a3..6f039784 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt @@ -122,14 +122,19 @@ enum class NotificationType( L.v { "$name notification data not found" } return -1 } - val notifContents = response.data.getUnreadNotifications(data).filter { notif -> - val inText = notif.text.let { text -> - Prefs.notificationKeywords.none { text.contains(it, true) } + + /** + * 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 inTitle = notif.title?.let { title -> - Prefs.notificationKeywords.none { title.contains(it, true) } - } ?: false - inText || inTitle + } + + val notifContents = response.data.getUnreadNotifications(data).filter { notif -> + validText(notif.title) && validText(notif.text) } if (notifContents.isEmpty()) return 0 val userId = data.id |