Force a prekey rotation when a prekey message to our PNI fails to decrypt.

This commit is contained in:
Greyson Parrelli
2026-09-10 17:10:15 -04:00
committed by Cody Henthorne
parent 28c69c8a0a
commit 94fcf2b2f1
2 changed files with 17 additions and 2 deletions
@@ -106,7 +106,14 @@ class PreKeysSyncJob private constructor(
Parameters.Builder()
.setQueue("PreKeysSyncJob")
.addConstraint(NetworkConstraint.KEY)
.setMaxInstancesForFactory(1)
.apply {
if (forceRotation) {
setMaxInstancesForFactory(Parameters.UNLIMITED)
setMaxInstancesForQueue(2)
} else {
setMaxInstancesForFactory(1)
}
}
.setMaxAttempts(Parameters.UNLIMITED)
.setLifespan(TimeUnit.DAYS.toMillis(30))
.build(),
@@ -326,7 +326,15 @@ object MessageDecryptor {
): Result {
if (ServiceId.parseOrNull(envelope.destinationServiceId, envelope.destinationServiceIdBinary) == SignalStore.account.pni) {
Log.w(TAG, "${logPrefix(envelope)} Decryption error for message sent to our PNI! Ignoring.")
return Result.Ignore(envelope, serverDeliveredTimestamp, followUpOperations)
if (envelope.type == Envelope.Type.PREKEY_MESSAGE) {
Log.w(TAG, "${logPrefix(envelope)} Decryption error was on a prekey message. Forcing a prekey rotation.", true)
followUpOperations += FollowUpOperation {
PreKeysSyncJob.create(forceRotationRequested = true).asChain()
}
}
return Result.Ignore(envelope, serverDeliveredTimestamp, followUpOperations.toUnmodifiableList())
}
val contentHint: ContentHint = ContentHint.fromType(protocolException.contentHint)