aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/services
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/services')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt19
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt4
2 files changed, 14 insertions, 9 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
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt
index 20a497e3..bba2a9a1 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt
@@ -46,14 +46,14 @@ fun setupNotificationChannels(c: Context) {
val manager = c.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val appName = c.string(R.string.frost_name)
val msg = c.string(R.string.messages)
+ manager.createNotificationChannel(NOTIF_CHANNEL_GENERAL, appName)
+ manager.createNotificationChannel(NOTIF_CHANNEL_MESSAGES, "$appName: $msg")
manager.notificationChannels
.filter {
it.id != NOTIF_CHANNEL_GENERAL &&
it.id != NOTIF_CHANNEL_MESSAGES
}
.forEach { manager.deleteNotificationChannel(it.id) }
- manager.createNotificationChannel(NOTIF_CHANNEL_GENERAL, appName)
- manager.createNotificationChannel(NOTIF_CHANNEL_MESSAGES, "$appName: $msg")
L.d { "Created notification channels: ${manager.notificationChannels.size} channels, ${manager.notificationChannelGroups.size} groups" }
}