Fix identity key update failure when profile key verification failed.

This commit is contained in:
Cody Henthorne
2025-08-01 13:31:29 -04:00
parent a60f3a26fb
commit e6e869e074
13 changed files with 79 additions and 32 deletions

View File

@@ -508,7 +508,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
db.runPostSuccessfulTransaction {
if (result.affectedIds.isNotEmpty()) {
result.affectedIds.forEach { AppDependencies.databaseObserver.notifyRecipientChanged(it) }
RetrieveProfileJob.enqueue(result.affectedIds)
RetrieveProfileJob.enqueue(result.affectedIds, skipDebounce = true)
}
if (result.oldIds.isNotEmpty()) {
@@ -1653,6 +1653,35 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
return false
}
/**
* Clears the profile key.
*
* It clears out the profile key credential and resets the unidentified access mode.
*/
fun clearProfileKeyData(id: RecipientId) {
val selection = "$ID = ?"
val args = arrayOf(id.serialize())
val valuesToCompare = contentValuesOf(
PROFILE_KEY to null
)
val valuesToSet = contentValuesOf(
PROFILE_KEY to null,
EXPIRING_PROFILE_KEY_CREDENTIAL to null,
SEALED_SENDER_MODE to SealedSenderAccessMode.UNKNOWN.mode,
LAST_PROFILE_FETCH to 0
)
val updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, valuesToCompare)
if (update(updateQuery, valuesToSet)) {
rotateStorageId(id)
AppDependencies.databaseObserver.notifyRecipientChanged(id)
StorageSyncHelper.scheduleSyncForDataChange()
}
}
/**
* Sets the profile key iff currently null.
*