mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-15 07:28:30 +00:00
Fix crash importing recipients without identifiers.
This commit is contained in:
@@ -203,6 +203,10 @@ object ExportOddities {
|
||||
* These represent situations where we will skip importing a data frame due to the data being invalid.
|
||||
*/
|
||||
object ImportSkips {
|
||||
fun recipientWithoutId(): String {
|
||||
return log(0, " No aci, pni, or e164 available for recipient")
|
||||
}
|
||||
|
||||
fun fromRecipientNotFound(sentTimestamp: Long): String {
|
||||
return log(sentTimestamp, "Failed to find the fromRecipient for the message.")
|
||||
}
|
||||
|
||||
@@ -8,8 +8,10 @@ package org.thoughtcrime.securesms.backup.v2.importer
|
||||
import androidx.core.content.contentValuesOf
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.insertInto
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.core.util.toInt
|
||||
import org.signal.core.util.update
|
||||
import org.thoughtcrime.securesms.backup.v2.ImportSkips
|
||||
import org.thoughtcrime.securesms.backup.v2.proto.Contact
|
||||
import org.thoughtcrime.securesms.backup.v2.util.toLocal
|
||||
import org.thoughtcrime.securesms.database.IdentityTable
|
||||
@@ -28,14 +30,22 @@ import org.whispersystems.signalservice.api.push.ServiceId.PNI
|
||||
* Handles the importing of [Contact] models into the local database.
|
||||
*/
|
||||
object ContactArchiveImporter {
|
||||
fun import(contact: Contact): RecipientId {
|
||||
private val TAG = Log.tag(ContactArchiveImporter::class)
|
||||
|
||||
fun import(contact: Contact): RecipientId? {
|
||||
val aci = ACI.parseOrNull(contact.aci?.toByteArray())
|
||||
val pni = PNI.parseOrNull(contact.pni?.toByteArray())
|
||||
val e164 = contact.formattedE164
|
||||
|
||||
if (aci == null && pni == null && e164 == null) {
|
||||
Log.w(TAG, ImportSkips.recipientWithoutId())
|
||||
return null
|
||||
}
|
||||
|
||||
val id = SignalDatabase.recipients.getAndPossiblyMergePnpVerified(
|
||||
aci = aci,
|
||||
pni = pni,
|
||||
e164 = contact.formattedE164
|
||||
e164 = e164
|
||||
)
|
||||
|
||||
val profileKey = contact.profileKey?.toByteArray()
|
||||
|
||||
@@ -98,7 +98,7 @@ object RecipientArchiveProcessor {
|
||||
}
|
||||
|
||||
fun import(recipient: ArchiveRecipient, importState: ImportState) {
|
||||
val newId = when {
|
||||
val newId: RecipientId? = when {
|
||||
recipient.contact != null -> ContactArchiveImporter.import(recipient.contact)
|
||||
recipient.group != null -> GroupArchiveImporter.import(recipient.group)
|
||||
recipient.distributionList != null -> DistributionListArchiveImporter.import(recipient.distributionList, importState)
|
||||
|
||||
Reference in New Issue
Block a user