From 59cc8c636d1547481b2681c85fa9895059fcfbb2 Mon Sep 17 00:00:00 2001 From: Michelle Tang Date: Mon, 9 Jun 2025 14:59:28 -0400 Subject: [PATCH] Ignore non-existing recipients in notification profiles storage sync. --- .../securesms/storage/StorageSyncModels.kt | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/storage/StorageSyncModels.kt b/app/src/main/java/org/thoughtcrime/securesms/storage/StorageSyncModels.kt index ba2c47ca9d..d25bffbe84 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/storage/StorageSyncModels.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/storage/StorageSyncModels.kt @@ -467,18 +467,23 @@ object StorageSyncModels { private fun localToRemoteRecipients(recipientIds: List): List { return recipientIds.mapNotNull { id -> - val recipient = SignalDatabase.recipients.getRecordForSync(id) ?: throw AssertionError("Missing recipient for id") - when (recipient.recipientType) { - RecipientType.INDIVIDUAL -> { - RemoteRecipient(contact = RemoteRecipient.Contact(serviceId = recipient.serviceId?.toString() ?: "", e164 = recipient.e164 ?: "")) + val recipient = SignalDatabase.recipients.getRecordForSync(id) + if (recipient == null) { + Log.w(TAG, "Recipient $id from notification profile cannot be found") + null + } else { + when (recipient.recipientType) { + RecipientType.INDIVIDUAL -> { + RemoteRecipient(contact = RemoteRecipient.Contact(serviceId = recipient.serviceId?.toString() ?: "", e164 = recipient.e164 ?: "")) + } + RecipientType.GV1 -> { + RemoteRecipient(legacyGroupId = recipient.groupId!!.requireV1().decodedId.toByteString()) + } + RecipientType.GV2 -> { + RemoteRecipient(groupMasterKey = recipient.syncExtras.groupMasterKey!!.serialize().toByteString()) + } + else -> null } - RecipientType.GV1 -> { - RemoteRecipient(legacyGroupId = recipient.groupId!!.requireV1().decodedId.toByteString()) - } - RecipientType.GV2 -> { - RemoteRecipient(groupMasterKey = recipient.syncExtras.groupMasterKey!!.serialize().toByteString()) - } - else -> null } } }