fixed typo in easy invites request code

This commit is contained in:
Daniel Gultsch 2020-12-01 22:39:56 +01:00
parent 1f392a688d
commit 00e1a93014
2 changed files with 16 additions and 2 deletions

View File

@ -141,6 +141,20 @@ public abstract class AbstractParser {
return null; 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) { private static String prefixError(List<String> errorNames) {
if (errorNames.size() > 0) { if (errorNames.size() > 0) {
return errorNames.get(0)+'\u001f'; return errorNames.get(0)+'\u001f';

View File

@ -1630,7 +1630,7 @@ public class XmppConnectionService extends Service {
final IqPacket request = new IqPacket(IqPacket.TYPE.SET); final IqPacket request = new IqPacket(IqPacket.TYPE.SET);
request.setTo(jid); request.setTo(jid);
final Element command = request.addChild("command", Namespace.COMMANDS); final Element command = request.addChild("command", Namespace.COMMANDS);
command.setAttribute("node", Namespace.COMMANDS); command.setAttribute("node", Namespace.EASY_ONBOARDING_INVITE);
command.setAttribute("action", "execute"); command.setAttribute("action", "execute");
sendIqPacket(account, request, (a, response) -> { sendIqPacket(account, request, (a, response) -> {
if (response.getType() == IqPacket.TYPE.RESULT) { if (response.getType() == IqPacket.TYPE.RESULT) {
@ -1649,7 +1649,7 @@ public class XmppConnectionService extends Service {
callback.inviteRequestFailed(getString(R.string.unable_to_parse_invite)); callback.inviteRequestFailed(getString(R.string.unable_to_parse_invite));
Log.d(Config.LOGTAG, response.toString()); Log.d(Config.LOGTAG, response.toString());
} else if (response.getType() == IqPacket.TYPE.ERROR) { } else if (response.getType() == IqPacket.TYPE.ERROR) {
callback.inviteRequestFailed(IqParser.extractErrorMessage(response)); callback.inviteRequestFailed(IqParser.errorMessage(response));
} else { } else {
callback.inviteRequestFailed(getString(R.string.remote_server_timeout)); callback.inviteRequestFailed(getString(R.string.remote_server_timeout));
} }