From 00e1a93014d0a50a17ebc39a5ff23975fef773b2 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 1 Dec 2020 22:39:56 +0100 Subject: [PATCH] fixed typo in easy invites request code --- .../siacs/conversations/parser/AbstractParser.java | 14 ++++++++++++++ .../services/XmppConnectionService.java | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java index 6068af5ad..80390be43 100644 --- a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java +++ b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java @@ -141,6 +141,20 @@ public abstract class AbstractParser { return null; } + public static String errorMessage(Element packet) { + final Element error = packet.findChild("error"); + if (error != null && error.getChildren().size() > 0) { + final List errorNames = orderedElementNames(error.getChildren()); + final String text = error.findChildContent("text"); + if (text != null && !text.trim().isEmpty()) { + return text; + } else if (errorNames.size() > 0){ + return errorNames.get(0).replace("-"," "); + } + } + return null; + } + private static String prefixError(List errorNames) { if (errorNames.size() > 0) { return errorNames.get(0)+'\u001f'; diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 9adef0309..6ad1caf68 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1630,7 +1630,7 @@ public class XmppConnectionService extends Service { final IqPacket request = new IqPacket(IqPacket.TYPE.SET); request.setTo(jid); final Element command = request.addChild("command", Namespace.COMMANDS); - command.setAttribute("node", Namespace.COMMANDS); + command.setAttribute("node", Namespace.EASY_ONBOARDING_INVITE); command.setAttribute("action", "execute"); sendIqPacket(account, request, (a, response) -> { if (response.getType() == IqPacket.TYPE.RESULT) { @@ -1649,7 +1649,7 @@ public class XmppConnectionService extends Service { callback.inviteRequestFailed(getString(R.string.unable_to_parse_invite)); Log.d(Config.LOGTAG, response.toString()); } else if (response.getType() == IqPacket.TYPE.ERROR) { - callback.inviteRequestFailed(IqParser.extractErrorMessage(response)); + callback.inviteRequestFailed(IqParser.errorMessage(response)); } else { callback.inviteRequestFailed(getString(R.string.remote_server_timeout)); }