Add migration to cleanup some inconsistent DB state.

This commit is contained in:
Greyson Parrelli
2023-07-12 13:49:16 -04:00
committed by Clark Chen
parent 1b63bdec12
commit 6ca9cb6da1
9 changed files with 107 additions and 19 deletions

View File

@@ -112,18 +112,14 @@ public class SignalBaseIdentityKeyStore {
}
public void saveIdentityWithoutSideEffects(@NonNull RecipientId recipientId,
@NonNull ServiceId serviceId,
IdentityKey identityKey,
VerifiedStatus verifiedStatus,
boolean firstUse,
long timestamp,
boolean nonBlockingApproval)
{
Recipient recipient = Recipient.resolved(recipientId);
if (recipient.hasServiceId()) {
cache.save(recipient.requireServiceId().toString(), recipientId, identityKey, verifiedStatus, firstUse, timestamp, nonBlockingApproval);
} else {
Log.w(TAG, "[saveIdentity] No serviceId for " + recipient.getId(), new Throwable());
}
cache.save(serviceId.toString(), recipientId, identityKey, verifiedStatus, firstUse, timestamp, nonBlockingApproval);
}
public boolean isTrustedIdentity(SignalProtocolAddress address, IdentityKey identityKey, IdentityKeyStore.Direction direction) {

View File

@@ -11,6 +11,7 @@ import org.thoughtcrime.securesms.database.identity.IdentityRecordList;
import org.thoughtcrime.securesms.database.model.IdentityRecord;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.whispersystems.signalservice.api.push.ServiceId;
import java.util.List;
import java.util.Optional;
@@ -50,13 +51,14 @@ public class SignalIdentityKeyStore implements IdentityKeyStore {
}
public void saveIdentityWithoutSideEffects(@NonNull RecipientId recipientId,
@NonNull ServiceId serviceId,
IdentityKey identityKey,
VerifiedStatus verifiedStatus,
boolean firstUse,
long timestamp,
boolean nonBlockingApproval)
{
baseStore.saveIdentityWithoutSideEffects(recipientId, identityKey, verifiedStatus, firstUse, timestamp, nonBlockingApproval);
baseStore.saveIdentityWithoutSideEffects(recipientId, serviceId, identityKey, verifiedStatus, firstUse, timestamp, nonBlockingApproval);
}
@Override