Address corner case where contact details may not be synced.

Relates to #12293
fork-5.53.8
Greyson Parrelli 2022-06-17 09:54:22 -04:00
rodzic 008f153b66
commit 2620a8fc51
3 zmienionych plików z 17 dodań i 1 usunięć

Wyświetl plik

@ -19,6 +19,7 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.signal.core.util.SetUtil;
import org.thoughtcrime.securesms.util.Util;
import java.io.IOException;
import java.util.List;
@ -69,13 +70,19 @@ public class ContactsSyncAdapter extends AbstractThreadedSyncAdapter {
Log.w(TAG, e);
}
} else if (unknownSystemE164s.size() > 0) {
Log.i(TAG, "There are " + unknownSystemE164s.size() + " unknown contacts. Doing an individual sync.");
List<Recipient> recipients = Stream.of(unknownSystemE164s)
.filter(s -> s.startsWith("+"))
.map(s -> Recipient.external(getContext(), s))
.toList();
Log.i(TAG, "There are " + unknownSystemE164s.size() + " unknown E164s, which are now " + recipients.size() + " recipients. Only syncing these specific contacts.");
try {
ContactDiscovery.refresh(context, recipients, true);
if (Util.isDefaultSmsProvider(context)) {
ContactDiscovery.syncRecipientInfoWithSystemContacts(context);
}
} catch (IOException e) {
Log.w(TAG, "Failed to refresh! Scheduling for later.", e);
ApplicationDependencies.getJobManager().add(new DirectoryRefreshJob(true));

Wyświetl plik

@ -134,6 +134,11 @@ object ContactDiscovery {
@JvmStatic
@WorkerThread
fun syncRecipientInfoWithSystemContacts(context: Context) {
if (!hasContactsPermissions(context)) {
Log.w(TAG, "[syncRecipientInfoWithSystemContacts] No contacts permission, skipping.")
return
}
syncRecipientsWithSystemContacts(
context = context,
rewrites = emptyMap(),

Wyświetl plik

@ -96,6 +96,10 @@ class ContactDiscoveryRefreshV1 {
.map(Recipient::requireE164)
.collect(Collectors.toSet());
if (numbers.size() < recipients.size()) {
Log.w(TAG, "We were asked to refresh " + recipients.size() + " numbers, but filtered that down to " + numbers.size());
}
return refreshNumbers(context, numbers, numbers);
}