fixed typo in easy invites request code

(cherry picked from commit 00e1a93014)
This commit is contained in:
Daniel Gultsch 2020-12-01 22:39:56 +01:00 committed by Christian Schneppe
parent e6cd5021e1
commit 0db4216f9b
No known key found for this signature in database
GPG key ID: F30B8D686B44D87E
2 changed files with 16 additions and 2 deletions

View file

@ -139,6 +139,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<String> 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<String> errorNames) {
if (errorNames.size() > 0) {
return errorNames.get(0) + '\u001f';

View file

@ -1876,7 +1876,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) {
@ -1895,7 +1895,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));
}