Discard notifications when not registered to prevent crash (#3784)

* Discard notifications when not registered to prevent crash

* Add same check to Wear
This commit is contained in:
Joris Pelgröm 2023-08-11 21:22:29 +02:00 committed by GitHub
parent 2650ca72c6
commit 01326db427
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -296,6 +296,10 @@ class MessagingManager @Inject constructor(
val serverId = jsonData[NotificationData.WEBHOOK_ID]?.let { webhookId ->
serverManager.getServer(webhookId = webhookId)?.id
} ?: ServerManager.SERVER_ID_ACTIVE
if (serverManager.getServer(serverId) == null) {
Log.w(TAG, "Received notification but no server for it, discarding")
return
}
jsonData = jsonData + mutableMapOf<String, String>().apply { put(THIS_SERVER_ID, serverId.toString()) }
mainScope.launch {

View file

@ -55,6 +55,10 @@ class MessagingManager @Inject constructor(
val notificationRow =
NotificationItem(0, now, notificationData[NotificationData.MESSAGE].toString(), jsonObject.toString(), source, serverId)
notificationDao.add(notificationRow)
if (serverManager.getServer(serverId) == null) {
Log.w(TAG, "Received notification but no server for it, discarding")
return
}
mainScope.launch {
val allowCommands = serverManager.integrationRepository(serverId).isTrusted()