Address corner case where contact details may not be synced.
Relates to #12293
This commit is contained in:
parent
008f153b66
commit
2620a8fc51
3 changed files with 17 additions and 1 deletions
|
@ -19,6 +19,7 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||||
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter;
|
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.signal.core.util.SetUtil;
|
import org.signal.core.util.SetUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -69,13 +70,19 @@ public class ContactsSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
}
|
}
|
||||||
} else if (unknownSystemE164s.size() > 0) {
|
} else if (unknownSystemE164s.size() > 0) {
|
||||||
Log.i(TAG, "There are " + unknownSystemE164s.size() + " unknown contacts. Doing an individual sync.");
|
|
||||||
List<Recipient> recipients = Stream.of(unknownSystemE164s)
|
List<Recipient> recipients = Stream.of(unknownSystemE164s)
|
||||||
.filter(s -> s.startsWith("+"))
|
.filter(s -> s.startsWith("+"))
|
||||||
.map(s -> Recipient.external(getContext(), s))
|
.map(s -> Recipient.external(getContext(), s))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
|
Log.i(TAG, "There are " + unknownSystemE164s.size() + " unknown E164s, which are now " + recipients.size() + " recipients. Only syncing these specific contacts.");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ContactDiscovery.refresh(context, recipients, true);
|
ContactDiscovery.refresh(context, recipients, true);
|
||||||
|
|
||||||
|
if (Util.isDefaultSmsProvider(context)) {
|
||||||
|
ContactDiscovery.syncRecipientInfoWithSystemContacts(context);
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.w(TAG, "Failed to refresh! Scheduling for later.", e);
|
Log.w(TAG, "Failed to refresh! Scheduling for later.", e);
|
||||||
ApplicationDependencies.getJobManager().add(new DirectoryRefreshJob(true));
|
ApplicationDependencies.getJobManager().add(new DirectoryRefreshJob(true));
|
||||||
|
|
|
@ -134,6 +134,11 @@ object ContactDiscovery {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
fun syncRecipientInfoWithSystemContacts(context: Context) {
|
fun syncRecipientInfoWithSystemContacts(context: Context) {
|
||||||
|
if (!hasContactsPermissions(context)) {
|
||||||
|
Log.w(TAG, "[syncRecipientInfoWithSystemContacts] No contacts permission, skipping.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
syncRecipientsWithSystemContacts(
|
syncRecipientsWithSystemContacts(
|
||||||
context = context,
|
context = context,
|
||||||
rewrites = emptyMap(),
|
rewrites = emptyMap(),
|
||||||
|
|
|
@ -96,6 +96,10 @@ class ContactDiscoveryRefreshV1 {
|
||||||
.map(Recipient::requireE164)
|
.map(Recipient::requireE164)
|
||||||
.collect(Collectors.toSet());
|
.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);
|
return refreshNumbers(context, numbers, numbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue