Improving handling of profile key updates for ourselves.

This commit is contained in:
Greyson Parrelli 2022-02-17 10:56:00 -05:00
parent 6f788ee3df
commit ecc6a7b95e
2 changed files with 8 additions and 2 deletions

View file

@ -933,7 +933,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
}
}
val updateCount = writableDatabase.update(TABLE_NAME, values, STORAGE_SERVICE_ID + " = ?", arrayOf(Base64.encodeBytes(update.old.id.raw)))
val updateCount = writableDatabase.update(TABLE_NAME, values, "$STORAGE_SERVICE_ID = ?", arrayOf(Base64.encodeBytes(update.old.id.raw)))
if (updateCount < 1) {
throw AssertionError("Account update didn't match any rows!")
}

View file

@ -170,6 +170,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@ -1772,7 +1773,12 @@ public final class MessageContentProcessor {
RecipientDatabase database = SignalDatabase.recipients();
ProfileKey messageProfileKey = ProfileKeyUtil.profileKeyOrNull(messageProfileKeyBytes);
if (messageProfileKey != null) {
if (senderRecipient.isSelf()) {
if (!Objects.equals(ProfileKeyUtil.getSelfProfileKey(), messageProfileKey)) {
warn(content.getTimestamp(), "Saw a sync message whose profile key doesn't match our records. Scheduling a storage sync to check.");
StorageSyncHelper.scheduleSyncForDataChange();
}
} else if (messageProfileKey != null) {
if (database.setProfileKey(senderRecipient.getId(), messageProfileKey)) {
log(content.getTimestamp(), "Profile key on message from " + senderRecipient.getId() + " didn't match our local store. It has been updated.");
ApplicationDependencies.getJobManager().add(RetrieveProfileJob.forRecipient(senderRecipient.getId()));