Add more checks when doing KT.

This commit is contained in:
Michelle Tang
2026-02-03 12:55:37 -05:00
parent 5a19117850
commit 0570aaeb6e
2 changed files with 12 additions and 4 deletions

View File

@@ -22,15 +22,18 @@ object VerifySafetyNumberRepository {
* Given a recipient will try to verify via search (first time) or monitor (subsequent).
*/
suspend fun verifyAutomatically(recipient: Recipient): VerifyResult {
if (recipient.aci.isEmpty || recipient.e164.isEmpty) {
val profileKey = ProfileKeyUtil.profileKeyOrNull(recipient.profileKey)
val identityRecord = AppDependencies.protocolStore.aci().identities().getIdentityRecord(recipient.id)
if (recipient.aci.isEmpty || recipient.e164.isEmpty || profileKey == null || identityRecord.isEmpty) {
Log.w(TAG, "Unable to verify automatically because of missing aci, e164, profile key, or identity record.")
return VerifyResult.UnretryableFailure
}
val identityRecord = AppDependencies.protocolStore.aci().identities().getIdentityRecord(recipient.id)
val aciIdentityKey = identityRecord.get().identityKey
val aci = recipient.requireAci().libSignalAci
val e164 = recipient.requireE164()
val unidentifiedAccessKey = ProfileKeyUtil.profileKeyOrNull(recipient.profileKey).let { UnidentifiedAccess.deriveAccessKeyFrom(it) }
val unidentifiedAccessKey = profileKey.let { UnidentifiedAccess.deriveAccessKeyFrom(it) }
val firstSearch = recipient.keyTransparencyData == null
val result = if (firstSearch) {

View File

@@ -20,6 +20,7 @@ import org.signal.core.util.logging.Log
import org.signal.libsignal.protocol.IdentityKey
import org.signal.libsignal.protocol.fingerprint.Fingerprint
import org.signal.libsignal.protocol.fingerprint.NumericFingerprintGenerator
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil
import org.thoughtcrime.securesms.crypto.ReentrantSessionLock
import org.thoughtcrime.securesms.database.IdentityTable
import org.thoughtcrime.securesms.database.SignalDatabase
@@ -53,7 +54,11 @@ class VerifySafetyNumberViewModel(
}
private fun checkAutomaticVerificationEligibility() {
if (recipient.get().e164.isEmpty || recipient.get().aci.isEmpty || SignalStore.misc.hasKeyTransparencyFailure) {
if (recipient.get().e164.isEmpty ||
recipient.get().aci.isEmpty ||
ProfileKeyUtil.profileKeyOrNull(recipient.get().profileKey) == null ||
SignalStore.misc.hasKeyTransparencyFailure
) {
automaticVerificationLiveData.postValue(AutomaticVerificationStatus.UNAVAILABLE_PERMANENT)
}
}