Add ContactDiscovery abstraction for doing CDS refreshes.

This commit is contained in:
Greyson Parrelli
2022-03-18 13:33:23 -04:00
parent 3c2bd032ba
commit 83c3b16b92
18 changed files with 87 additions and 46 deletions

View File

@@ -9,7 +9,7 @@ import androidx.annotation.WorkerThread;
import com.annimon.stream.Stream;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.contacts.sync.DirectoryHelper;
import org.thoughtcrime.securesms.contacts.sync.ContactDiscovery;
import org.thoughtcrime.securesms.database.GroupDatabase;
import org.thoughtcrime.securesms.database.RecipientDatabase.RegisteredState;
import org.thoughtcrime.securesms.database.SignalDatabase;
@@ -56,7 +56,7 @@ public class RecipientUtil {
if (!recipient.getServiceId().isPresent()) {
Log.i(TAG, recipient.getId() + " is missing a UUID...");
RegisteredState state = DirectoryHelper.refreshDirectoryFor(context, recipient, false);
RegisteredState state = ContactDiscovery.refresh(context, recipient, false);
recipient = Recipient.resolved(recipient.getId());
Log.i(TAG, "Successfully performed a UUID fetch for " + recipient.getId() + ". Registered: " + state);
@@ -98,7 +98,7 @@ public class RecipientUtil {
.toList();
if (recipientsWithoutUuids.size() > 0) {
DirectoryHelper.refreshDirectoryFor(context, recipientsWithoutUuids, false);
ContactDiscovery.refresh(context, recipientsWithoutUuids, false);
if (recipients.stream().map(Recipient::resolve).anyMatch(Recipient::isUnregistered)) {
throw new NotFoundException("1 or more recipients are not registered!");

View File

@@ -8,7 +8,7 @@ import androidx.core.util.Consumer;
import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.contacts.sync.DirectoryHelper;
import org.thoughtcrime.securesms.contacts.sync.ContactDiscovery;
import org.thoughtcrime.securesms.database.GroupDatabase;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.database.model.IdentityRecord;
@@ -66,7 +66,7 @@ final class RecipientDialogRepository {
void refreshRecipient() {
SignalExecutors.UNBOUNDED.execute(() -> {
try {
DirectoryHelper.refreshDirectoryFor(context, Recipient.resolved(recipientId), false);
ContactDiscovery.refresh(context, Recipient.resolved(recipientId), false);
} catch (IOException e) {
Log.w(TAG, "Failed to refresh user after adding to contacts.");
}