From f2e88bb0de1470766bfc1687754129ea7fa314fc Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Sat, 21 May 2022 19:28:54 -0500 Subject: [PATCH 1/2] Skip contact sync work if there are no gateways configured Or if syncing before gateways have been discovered, etc. Don't do the work if we know nothing will come of it. --- .../conversations/services/QuickConversationsService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cheogram/java/eu/siacs/conversations/services/QuickConversationsService.java b/src/cheogram/java/eu/siacs/conversations/services/QuickConversationsService.java index b12bd1c3633a7f229c04e549ad1947278dba4777..9c72ceff15d34a7f4bfc3467dc7d377cc016014d 100644 --- a/src/cheogram/java/eu/siacs/conversations/services/QuickConversationsService.java +++ b/src/cheogram/java/eu/siacs/conversations/services/QuickConversationsService.java @@ -97,9 +97,11 @@ public class QuickConversationsService extends AbstractQuickConversationsService } protected void considerSync(boolean forced) { - final ImmutableMap allContacts = PhoneNumberContact.load(service); + ImmutableMap allContacts = null; for (final Account account : service.getAccounts()) { List gateways = gateways(account); + if (gateways.size() < 1) continue; + if (allContacts == null) allContacts = PhoneNumberContact.load(service); refresh(account, gateways, allContacts.values()); if (!considerSync(account, gateways, allContacts, forced)) { service.syncRoster(account); From aab94fd0ce0ec1fe431664f6dbd3ca6c0d09b1d8 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Sat, 21 May 2022 19:29:39 -0500 Subject: [PATCH 2/2] Contact sync needs to happen when we discover a new gateway Since that can change the outcome of the sync operation. --- .../eu/siacs/conversations/services/XmppConnectionService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 33abf63974502ab763f01d8018056272af97b9a0..a62225b2bc364687b2451a0ae856b67e567a5ffc 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -4694,6 +4694,7 @@ public class XmppConnectionService extends Service { } if (disco.hasIdentity("gateway", "pstn")) { contact.registerAsPhoneAccount(this); + mQuickConversationsService.considerSyncBackground(false); } } else { final IqPacket request = new IqPacket(IqPacket.TYPE.GET); @@ -4714,6 +4715,7 @@ public class XmppConnectionService extends Service { if (discoveryResult.hasIdentity("gateway", "pstn")) { final Contact contact = account.getRoster().getContact(jid); contact.registerAsPhoneAccount(this); + mQuickConversationsService.considerSyncBackground(false); } } else { Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": mismatch in caps for contact " + jid + " " + presence.getVer() + " vs " + discoveryResult.getVer());