From 971bb60f4288d160fd9560bdf128c4ff9b431ca0 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 12 Jun 2020 20:06:49 +0200 Subject: [PATCH] add more logging to caps fetching --- .../services/XmppConnectionService.java | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index a6cc30e98..484ed3c0a 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2778,6 +2778,7 @@ public class XmppConnectionService extends Service { updateConversationUi(); } } + private void fetchConferenceMembers(final Conversation conversation) { final Account account = conversation.getAccount(); final AxolotlService axolotlService = account.getAxolotlService(); @@ -3304,7 +3305,7 @@ public class XmppConnectionService extends Service { } public void createMessageAsync(final Message message) { - mDatabaseWriterExecutor.execute(()-> databaseBackend.createMessage(message)); + mDatabaseWriterExecutor.execute(() -> databaseBackend.createMessage(message)); } public void updateMessage(Message message, String uuid) { @@ -4444,34 +4445,38 @@ public class XmppConnectionService extends Service { public void fetchCaps(Account account, final Jid jid, final Presence presence) { final Pair key = new Pair<>(presence.getHash(), presence.getVer()); - ServiceDiscoveryResult disco = getCachedServiceDiscoveryResult(key); + final ServiceDiscoveryResult disco = getCachedServiceDiscoveryResult(key); if (disco != null) { presence.setServiceDiscoveryResult(disco); } else { - if (!account.inProgressDiscoFetches.contains(key)) { - account.inProgressDiscoFetches.add(key); - IqPacket request = new IqPacket(IqPacket.TYPE.GET); - request.setTo(jid); - final String node = presence.getNode(); - final String ver = presence.getVer(); - final Element query = request.query(Namespace.DISCO_INFO); - if (node != null && ver != null) { - query.setAttribute("node", node + "#" + ver); - } - Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": making disco request for " + key.second + " to " + jid); - sendIqPacket(account, request, (a, response) -> { - if (response.getType() == IqPacket.TYPE.RESULT) { - ServiceDiscoveryResult discoveryResult = new ServiceDiscoveryResult(response); - if (presence.getVer().equals(discoveryResult.getVer())) { - databaseBackend.insertDiscoveryResult(discoveryResult); - injectServiceDiscoveryResult(a.getRoster(), presence.getHash(), presence.getVer(), discoveryResult); - } else { - Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": mismatch in caps for contact " + jid + " " + presence.getVer() + " vs " + discoveryResult.getVer()); - } - } - a.inProgressDiscoFetches.remove(key); - }); + if (account.inProgressDiscoFetches.contains(key)) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": skipping duplicate disco request for " + key.second + " to " + jid); + return; } + account.inProgressDiscoFetches.add(key); + final IqPacket request = new IqPacket(IqPacket.TYPE.GET); + request.setTo(jid); + final String node = presence.getNode(); + final String ver = presence.getVer(); + final Element query = request.query(Namespace.DISCO_INFO); + if (node != null && ver != null) { + query.setAttribute("node", node + "#" + ver); + } + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": making disco request for " + key.second + " to " + jid); + sendIqPacket(account, request, (a, response) -> { + if (response.getType() == IqPacket.TYPE.RESULT) { + ServiceDiscoveryResult discoveryResult = new ServiceDiscoveryResult(response); + if (presence.getVer().equals(discoveryResult.getVer())) { + databaseBackend.insertDiscoveryResult(discoveryResult); + injectServiceDiscoveryResult(a.getRoster(), presence.getHash(), presence.getVer(), discoveryResult); + } else { + Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": mismatch in caps for contact " + jid + " " + presence.getVer() + " vs " + discoveryResult.getVer()); + } + } else { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to fetch caps from " + jid); + } + a.inProgressDiscoFetches.remove(key); + }); } }