Ensure we have a storageId for self.

This commit is contained in:
Greyson Parrelli 2021-04-29 17:55:34 -04:00
parent dc6dc192dc
commit 2f30d29351
2 changed files with 12 additions and 5 deletions

View file

@ -214,11 +214,17 @@ public class StorageSyncJob extends BaseJob {
final SignalStorageManifest localManifest = SignalStore.storageService().getManifest();
final SignalStorageManifest remoteManifest = accountManager.getStorageManifestIfDifferentVersion(storageServiceKey, localManifest.getVersion()).or(localManifest);
stopwatch.split("remote-manifest");
Recipient self = Recipient.self().fresh();
boolean needsMultiDeviceSync = false;
boolean needsForcePush = false;
stopwatch.split("remote-manifest");
if (self.getStorageServiceId() == null) {
Log.w(TAG, "No storageId for self. Generating.");
DatabaseFactory.getRecipientDatabase(context).updateStorageId(self.getId(), StorageSyncHelper.generateKey());
self = Recipient.self().fresh();
}
Log.i(TAG, "Our version: " + localManifest.getVersion() + ", their version: " + remoteManifest.getVersion());

View file

@ -1,5 +1,6 @@
package org.whispersystems.signalservice.api.storage;
import org.whispersystems.libsignal.util.guava.Preconditions;
import org.whispersystems.signalservice.internal.storage.protos.ManifestRecord;
import java.util.Arrays;
@ -10,19 +11,19 @@ public class StorageId {
private final byte[] raw;
public static StorageId forContact(byte[] raw) {
return new StorageId(ManifestRecord.Identifier.Type.CONTACT_VALUE, raw);
return new StorageId(ManifestRecord.Identifier.Type.CONTACT_VALUE, Preconditions.checkNotNull(raw));
}
public static StorageId forGroupV1(byte[] raw) {
return new StorageId(ManifestRecord.Identifier.Type.GROUPV1_VALUE, raw);
return new StorageId(ManifestRecord.Identifier.Type.GROUPV1_VALUE, Preconditions.checkNotNull(raw));
}
public static StorageId forGroupV2(byte[] raw) {
return new StorageId(ManifestRecord.Identifier.Type.GROUPV2_VALUE, raw);
return new StorageId(ManifestRecord.Identifier.Type.GROUPV2_VALUE, Preconditions.checkNotNull(raw));
}
public static StorageId forAccount(byte[] raw) {
return new StorageId(ManifestRecord.Identifier.Type.ACCOUNT_VALUE, raw);
return new StorageId(ManifestRecord.Identifier.Type.ACCOUNT_VALUE, Preconditions.checkNotNull(raw));
}
public static StorageId forType(byte[] raw, int type) {