Don't run UuidMigration if not registered.

This commit is contained in:
Greyson Parrelli 2019-11-13 10:42:37 -05:00 committed by Alan Evans
parent b9da012cc4
commit 2924a09936
2 changed files with 6 additions and 2 deletions

View file

@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.migrations; package org.thoughtcrime.securesms.migrations;
import android.content.Context; import android.content.Context;
import android.text.TextUtils;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -52,8 +53,9 @@ public class UuidMigrationJob extends MigrationJob {
@Override @Override
void performMigration() throws Exception { void performMigration() throws Exception {
if (!TextSecurePreferences.isPushRegistered(context)) { if (!TextSecurePreferences.isPushRegistered(context) || TextUtils.isEmpty(TextSecurePreferences.getLocalNumber(context))) {
Log.w(TAG, "Not registered! Skipping migration, as it wouldn't do anything."); Log.w(TAG, "Not registered! Skipping migration, as it wouldn't do anything.");
return;
} }
fetchOwnUuid(context); fetchOwnUuid(context);

View file

@ -85,8 +85,10 @@ public final class LiveRecipientCache {
if (localUuid != null) { if (localUuid != null) {
localRecipientId = recipientDatabase.getByUuid(localUuid).or(recipientDatabase.getByE164(localE164)).orNull(); localRecipientId = recipientDatabase.getByUuid(localUuid).or(recipientDatabase.getByE164(localE164)).orNull();
} else { } else if (localE164 != null) {
localRecipientId = recipientDatabase.getByE164(localE164).orNull(); localRecipientId = recipientDatabase.getByE164(localE164).orNull();
} else {
throw new AssertionError("Tried to call getSelf() before local data was set!");
} }
if (localRecipientId == null) { if (localRecipientId == null) {