Fix issue with group storage sync.

fork-5.53.8
Greyson Parrelli 2020-04-23 13:33:48 -04:00
rodzic 0ca2848e01
commit eedbcdd564
4 zmienionych plików z 32 dodań i 16 usunięć

Wyświetl plik

@ -1458,10 +1458,12 @@ public class RecipientDatabase extends Database {
}
void markDirty(@NonNull RecipientId recipientId, @NonNull DirtyState dirtyState) {
Log.d(TAG, "Attempting to mark " + recipientId + " with dirty state " + dirtyState, new Throwable());
ContentValues contentValues = new ContentValues(1);
contentValues.put(DIRTY, dirtyState.getId());
String query = ID + " = ? AND (" + UUID + " NOT NULL OR " + PHONE + " NOT NULL) AND ";
String query = ID + " = ? AND (" + UUID + " NOT NULL OR " + PHONE + " NOT NULL OR " + GROUP_ID + " NOT NULL) AND ";
String[] args = new String[] { recipientId.serialize(), String.valueOf(dirtyState.id) };
switch (dirtyState) {

Wyświetl plik

@ -275,7 +275,7 @@ public class StorageSyncJob extends BaseJob {
case ManifestRecord.Identifier.Type.GROUPV2_VALUE:
RecipientSettings settings = recipientDatabase.getByStorageId(id.getRaw());
if (settings != null) {
records.add(StorageSyncModels.localToRemoteRecord(settings, archivedRecipients));
} else {
Log.w(TAG, "Missing local recipient model! Type: " + id.getType());
}

Wyświetl plik

@ -133,25 +133,38 @@ public final class StorageSyncHelper {
}
for (RecipientSettings update : updates) {
byte[] oldKey = update.getStorageId();
byte[] newKey = generateKey();
StorageId oldId;
StorageId newId;
storageInserts.add(StorageSyncModels.localToRemoteRecord(update, newKey, archivedRecipients));
storageDeletes.add(ByteBuffer.wrap(oldKey));
completeIds.remove(StorageId.forContact(oldKey));
completeIds.add(StorageId.forContact(newKey));
storageKeyUpdates.put(update.getId(), newKey);
switch (update.getGroupType()) {
case NONE:
oldId = StorageId.forContact(update.getStorageId());
newId = StorageId.forContact(generateKey());
break;
case SIGNAL_V1:
oldId = StorageId.forGroupV1(update.getStorageId());
newId = StorageId.forGroupV1(generateKey());
break;
default:
throw new AssertionError("Unsupported type!");
}
storageInserts.add(StorageSyncModels.localToRemoteRecord(update, newId.getRaw(), archivedRecipients));
storageDeletes.add(ByteBuffer.wrap(oldId.getRaw()));
completeIds.remove(oldId);
completeIds.add(newId);
storageKeyUpdates.put(update.getId(), newId.getRaw());
}
if (accountUpdate.isPresent()) {
byte[] oldKey = accountUpdate.get().getId().getRaw();
byte[] newKey = generateKey();
StorageId oldId = accountUpdate.get().getId();
StorageId newId = StorageId.forAccount(generateKey());
storageInserts.add(SignalStorageRecord.forAccount(StorageId.forAccount(newKey), accountUpdate.get()));
storageDeletes.add(ByteBuffer.wrap(oldKey));
completeIds.remove(StorageId.forAccount(oldKey));
completeIds.add(StorageId.forAccount(newKey));
storageKeyUpdates.put(Recipient.self().getId(), newKey);
storageInserts.add(SignalStorageRecord.forAccount(newId, accountUpdate.get()));
storageDeletes.add(ByteBuffer.wrap(oldId.getRaw()));
completeIds.remove(oldId);
completeIds.add(newId);
storageKeyUpdates.put(Recipient.self().getId(), newId.getRaw());
}
if (storageInserts.isEmpty() && storageDeletes.isEmpty()) {

Wyświetl plik

@ -9,6 +9,7 @@ import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.storage.SignalContactRecord;
import org.whispersystems.signalservice.api.storage.SignalGroupV1Record;
import org.whispersystems.signalservice.api.storage.SignalStorageRecord;
import org.whispersystems.signalservice.api.storage.StorageId;
import org.whispersystems.signalservice.internal.storage.protos.ContactRecord.IdentityState;
import java.util.Set;