fix: Do not crash when adding a watchtower alert for a missing cipher item

This commit is contained in:
Artem Chepurnoy 2024-06-19 08:11:39 +03:00
parent f8c77ea34d
commit 67ace9692d
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
1 changed files with 12 additions and 8 deletions

View File

@ -145,14 +145,18 @@ private class WatchtowerClient(
val results = processor.process(ciphers)
db.transaction {
results.forEach { r ->
db.watchtowerThreatQueries.upsert(
value = r.value,
threat = r.threat && !r.cipher.deleted,
cipherId = r.cipher.id,
type = type,
reportedAt = now,
version = version,
)
// We might be inserting a threat report on a cipher that
// does not exist anymore. This is fine, just ignore it.
runCatching {
db.watchtowerThreatQueries.upsert(
value = r.value,
threat = r.threat && !r.cipher.deleted,
cipherId = r.cipher.id,
type = type,
reportedAt = now,
version = version,
)
}
}
}
}