do not invoke onPushFailed() on timeout

This commit is contained in:
Daniel Gultsch 2018-05-01 17:35:29 +02:00
parent 8d5a7c79da
commit d3b20544c9
2 changed files with 13 additions and 7 deletions

View File

@ -574,8 +574,9 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() { mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() {
@Override @Override
public void onIqPacketReceived(Account account, IqPacket packet) { public void onIqPacketReceived(Account account, IqPacket packet) {
Element error = packet.getType() == IqPacket.TYPE.ERROR ? packet.findChild("error") : null; final Element error = packet.getType() == IqPacket.TYPE.ERROR ? packet.findChild("error") : null;
if (firstAttempt && error != null && error.hasChild("precondition-not-met", Namespace.PUBSUB_ERROR)) { final boolean preConditionNotMet = error != null && error.hasChild("precondition-not-met", Namespace.PUBSUB_ERROR);
if (firstAttempt && preConditionNotMet) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": precondition wasn't met for device list. pushing node configuration"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": precondition wasn't met for device list. pushing node configuration");
mXmppConnectionService.pushNodeConfiguration(account, AxolotlService.PEP_DEVICE_LIST, publishOptions, new XmppConnectionService.OnConfigurationPushed() { mXmppConnectionService.pushNodeConfiguration(account, AxolotlService.PEP_DEVICE_LIST, publishOptions, new XmppConnectionService.OnConfigurationPushed() {
@Override @Override
@ -595,9 +596,14 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
mXmppConnectionService.databaseBackend.updateAccount(account); mXmppConnectionService.databaseBackend.updateAccount(account);
} }
if (packet.getType() == IqPacket.TYPE.ERROR) { if (packet.getType() == IqPacket.TYPE.ERROR) {
if (preConditionNotMet) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": pre condition still not met on second attempt");
} else if (error != null) {
pepBroken = true; pepBroken = true;
Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing own device id" + packet.findChild("error")); Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing own device id" + packet.findChild("error"));
} }
}
} }
} }
}); });

View File

@ -2546,15 +2546,15 @@ public class XmppConnectionService extends Service {
public void onIqPacketReceived(Account account, IqPacket packet) { public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT && callback != null) { if (packet.getType() == IqPacket.TYPE.RESULT && callback != null) {
callback.onPushSucceeded(); callback.onPushSucceeded();
} else { } else if (packet.getType() == IqPacket.TYPE.ERROR && callback != null) {
Log.d(Config.LOGTAG, packet.toString()); callback.onPushFailed();
} }
} }
}); });
} else if (callback != null) { } else if (callback != null) {
callback.onPushFailed(); callback.onPushFailed();
} }
} else if (callback != null) { } else if (packet.getType() == IqPacket.TYPE.ERROR && callback != null) {
callback.onPushFailed(); callback.onPushFailed();
} }
} }