Fix some storage service consistency issues.

fork-5.53.8
Greyson Parrelli 2020-04-24 18:37:12 -04:00
rodzic 33874a8866
commit 575caa53d3
4 zmienionych plików z 9 dodań i 8 usunięć

Wyświetl plik

@ -1174,13 +1174,9 @@ public class RecipientDatabase extends Database {
@Deprecated
public void setRegistered(@NonNull RecipientId id, RegisteredState registeredState) {
ContentValues contentValues = new ContentValues(2);
ContentValues contentValues = new ContentValues(1);
contentValues.put(REGISTERED, registeredState.getId());
if (registeredState == RegisteredState.REGISTERED) {
contentValues.put(STORAGE_SERVICE_ID, Base64.encodeBytes(StorageSyncHelper.generateKey()));
}
if (update(id, contentValues)) {
if (registeredState == RegisteredState.REGISTERED) {
markDirty(id, DirtyState.INSERT);

Wyświetl plik

@ -35,7 +35,7 @@ public class DirectoryRefreshJob extends BaseJob {
boolean notifyOfNewUsers)
{
this(new Job.Parameters.Builder()
.setQueue("DirectoryRefreshJob")
.setQueue(StorageSyncJob.QUEUE_KEY)
.addConstraint(NetworkConstraint.KEY)
.setMaxAttempts(10)
.build(),

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

@ -1,5 +1,8 @@
package org.thoughtcrime.securesms.registration;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
import org.thoughtcrime.securesms.jobs.StorageSyncJob;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.recipients.Recipient;
@ -21,7 +24,9 @@ public final class RegistrationUtil {
if (!SignalStore.registrationValues().isRegistrationComplete() && SignalStore.kbsValues().hasPin() && !Recipient.self().getProfileName().isEmpty()) {
Log.i(TAG, "Marking registration completed.", new Throwable());
SignalStore.registrationValues().setRegistrationComplete();
StorageSyncHelper.scheduleSyncForDataChange();
ApplicationDependencies.getJobManager().startChain(new StorageSyncJob())
.then(new DirectoryRefreshJob(false))
.enqueue();
} else if (!SignalStore.registrationValues().isRegistrationComplete()) {
Log.i(TAG, "Registration is not yet complete.", new Throwable());
}