mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-15 07:28:30 +00:00
Add more checks when doing KT.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user