aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/parser/AbstractParser.java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-02-21 19:45:12 +0100
committerChristian Schneppe <christian@pix-art.de>2019-02-21 19:45:12 +0100
commita5019812fbdaf57096b8483778b610fd3b0d1887 (patch)
treea435332fd2188c7a37163e5f3516d9e012480f82 /src/main/java/de/pixart/messenger/parser/AbstractParser.java
parent485609f30cf8771b5594c951029847ee6c0b634e (diff)
show file too large instead of generic delivery failed
Diffstat (limited to 'src/main/java/de/pixart/messenger/parser/AbstractParser.java')
-rw-r--r--src/main/java/de/pixart/messenger/parser/AbstractParser.java34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/AbstractParser.java b/src/main/java/de/pixart/messenger/parser/AbstractParser.java
index e0a26c18d..0b94102a5 100644
--- a/src/main/java/de/pixart/messenger/parser/AbstractParser.java
+++ b/src/main/java/de/pixart/messenger/parser/AbstractParser.java
@@ -2,6 +2,8 @@ package de.pixart.messenger.parser;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Locale;
import de.pixart.messenger.entities.Account;
@@ -126,14 +128,36 @@ public abstract class AbstractParser {
public static String extractErrorMessage(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 {
- return error.getChildren().get(0).getName().replace("-", " ");
+ return prefixError(errorNames) + text;
+ } else if (errorNames.size() > 0) {
+ return prefixError(errorNames) + errorNames.get(0).replace("-", " ");
+ }
+ }
+ return null;
+ }
+
+ private static String prefixError(List<String> errorNames) {
+ if (errorNames.size() > 0) {
+ return errorNames.get(0) + '\u001f';
+ }
+ return "";
+ }
+
+ private static List<String> orderedElementNames(List<Element> children) {
+ List<String> names = new ArrayList<>();
+ for (Element child : children) {
+ final String name = child.getName();
+ if (name != null && !name.equals("text")) {
+ if ("urn:ietf:params:xml:ns:xmpp-stanzas".equals(child.getNamespace())) {
+ names.add(name);
+ } else {
+ names.add(0, name);
+ }
}
- } else {
- return null;
}
+ return names;
}
}