mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-25 04:06:14 +00:00
Perform username deletion if no local name is set.
This commit is contained in:
committed by
Greyson Parrelli
parent
39f5aebbec
commit
a7bca89889
@@ -1,12 +1,9 @@
|
||||
package org.thoughtcrime.securesms.jobs
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Data
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
@@ -36,13 +33,7 @@ class NewRegistrationUsernameSyncJob private constructor(parameters: Parameters)
|
||||
override fun onFailure() = Unit
|
||||
|
||||
override fun onRun() {
|
||||
if (SignalDatabase.recipients.getUsername(Recipient.self().id).isNullOrEmpty()) {
|
||||
Log.i(TAG, "Clearing username from server.")
|
||||
ApplicationDependencies.getSignalServiceAccountManager().deleteUsername()
|
||||
} else {
|
||||
Log.i(TAG, "Local user has a username, attempting username synchronization.")
|
||||
RefreshOwnProfileJob.checkUsernameIsInSync()
|
||||
}
|
||||
RefreshOwnProfileJob.checkUsernameIsInSync()
|
||||
}
|
||||
|
||||
override fun onShouldRetry(e: Exception): Boolean {
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.signal.libsignal.usernames.BaseUsernameException;
|
||||
@@ -253,7 +252,17 @@ public class RefreshOwnProfileJob extends BaseJob {
|
||||
}
|
||||
}
|
||||
|
||||
static void checkUsernameIsInSync() {
|
||||
static void checkUsernameIsInSync() throws IOException {
|
||||
if (TextUtils.isEmpty(SignalDatabase.recipients().getUsername(Recipient.self().getId()))) {
|
||||
Log.i(TAG, "No local username. Clearing username from server.");
|
||||
ApplicationDependencies.getSignalServiceAccountManager().deleteUsername();
|
||||
} else {
|
||||
Log.i(TAG, "Local user has a username, attempting username synchronization.");
|
||||
performLocalRemoteComparison();
|
||||
}
|
||||
}
|
||||
|
||||
private static void performLocalRemoteComparison() {
|
||||
try {
|
||||
String localUsername = SignalDatabase.recipients().getUsername(Recipient.self().getId());
|
||||
boolean hasLocalUsername = !TextUtils.isEmpty(localUsername);
|
||||
|
||||
Reference in New Issue
Block a user