mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Ensure we enqueue a storage sync after a safety number change.
This commit is contained in:
committed by
Alex Hart
parent
55acd0f048
commit
dfcadde076
@@ -32,6 +32,7 @@ import org.thoughtcrime.securesms.database.model.IdentityStoreRecord;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.CursorUtil;
|
||||
import org.thoughtcrime.securesms.util.IdentityUtil;
|
||||
@@ -141,6 +142,7 @@ public class IdentityDatabase extends Database {
|
||||
{
|
||||
saveIdentityInternal(addressName, recipientId, identityKey, verifiedStatus, firstUse, timestamp, nonBlockingApproval);
|
||||
SignalDatabase.recipients().markNeedsSync(recipientId);
|
||||
StorageSyncHelper.scheduleSyncForDataChange();
|
||||
}
|
||||
|
||||
public void setApproval(@NonNull String addressName, @NonNull RecipientId recipientId, boolean nonBlockingApproval) {
|
||||
@@ -152,6 +154,7 @@ public class IdentityDatabase extends Database {
|
||||
database.update(TABLE_NAME, contentValues, ADDRESS + " = ?", SqlUtil.buildArgs(addressName));
|
||||
|
||||
SignalDatabase.recipients().markNeedsSync(recipientId);
|
||||
StorageSyncHelper.scheduleSyncForDataChange();
|
||||
}
|
||||
|
||||
public void setVerified(@NonNull String addressName, @NonNull RecipientId recipientId, IdentityKey identityKey, VerifiedStatus verifiedStatus) {
|
||||
@@ -169,11 +172,14 @@ public class IdentityDatabase extends Database {
|
||||
Optional<IdentityRecord> record = getIdentityRecord(addressName);
|
||||
if (record.isPresent()) EventBus.getDefault().post(record.get());
|
||||
SignalDatabase.recipients().markNeedsSync(recipientId);
|
||||
StorageSyncHelper.scheduleSyncForDataChange();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateIdentityAfterSync(@NonNull String addressName, @NonNull RecipientId recipientId, IdentityKey identityKey, VerifiedStatus verifiedStatus) {
|
||||
boolean hadEntry = getIdentityRecord(addressName).isPresent();
|
||||
Optional<IdentityRecord> existingRecord = getIdentityRecord(addressName);
|
||||
|
||||
boolean hadEntry = existingRecord.isPresent();
|
||||
boolean keyMatches = hasMatchingKey(addressName, identityKey);
|
||||
boolean statusMatches = keyMatches && hasMatchingStatus(addressName, identityKey, verifiedStatus);
|
||||
|
||||
@@ -190,7 +196,8 @@ public class IdentityDatabase extends Database {
|
||||
}
|
||||
|
||||
if (hadEntry && !keyMatches) {
|
||||
IdentityUtil.markIdentityUpdate(context, RecipientId.fromExternalPush(addressName));
|
||||
Log.w(TAG, "Updated identity key during storage sync for " + addressName + " | Existing: " + existingRecord.get().getIdentityKey().hashCode() + ", New: " + identityKey.hashCode());
|
||||
IdentityUtil.markIdentityUpdate(context, recipientId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user