mirror of
https://github.com/home-assistant/android
synced 2024-10-04 15:19:30 +00:00
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:
parent
2650ca72c6
commit
01326db427
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue