aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-12-31 02:46:35 +0300
committerGravatar Vitaly Takmazov2018-12-31 02:46:35 +0300
commit9599599d665e65f35d804eade620cf063ee723ff (patch)
tree1c1a40e5baabbb40d6e1ac77b2c2435fad5e778b /src/main
parent2273e26543e947bc9b227f7085187721ba2bfed4 (diff)
Add error payload to error messages
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/juick/server/XMPPManager.java25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/main/java/com/juick/server/XMPPManager.java b/src/main/java/com/juick/server/XMPPManager.java
index 9b886784..51b3b04e 100644
--- a/src/main/java/com/juick/server/XMPPManager.java
+++ b/src/main/java/com/juick/server/XMPPManager.java
@@ -19,11 +19,13 @@ package com.juick.server;
import com.juick.User;
import com.juick.formatters.PlainTextFormatter;
-import com.juick.server.www.WebApp;
-import com.juick.service.component.*;
import com.juick.model.CommandResult;
+import com.juick.server.www.WebApp;
import com.juick.server.xmpp.iq.MessageQuery;
-import com.juick.service.*;
+import com.juick.service.MessagesService;
+import com.juick.service.PMQueriesService;
+import com.juick.service.UserService;
+import com.juick.service.component.*;
import com.juick.util.MessageUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FilenameUtils;
@@ -39,7 +41,10 @@ import rocks.xmpp.core.session.XmppSession;
import rocks.xmpp.core.session.XmppSessionConfiguration;
import rocks.xmpp.core.session.debug.LogbackDebugger;
import rocks.xmpp.core.stanza.AbstractIQHandler;
-import rocks.xmpp.core.stanza.model.*;
+import rocks.xmpp.core.stanza.model.IQ;
+import rocks.xmpp.core.stanza.model.Message;
+import rocks.xmpp.core.stanza.model.Presence;
+import rocks.xmpp.core.stanza.model.StanzaError;
import rocks.xmpp.core.stanza.model.client.ClientMessage;
import rocks.xmpp.core.stanza.model.client.ClientPresence;
import rocks.xmpp.core.stanza.model.errors.Condition;
@@ -56,17 +61,12 @@ import rocks.xmpp.extensions.receipts.MessageDeliveryReceiptsManager;
import rocks.xmpp.extensions.vcard.temp.model.VCard;
import rocks.xmpp.extensions.version.SoftwareVersionManager;
import rocks.xmpp.extensions.version.model.SoftwareVersion;
-import rocks.xmpp.util.XmppUtils;
import javax.annotation.Nonnull;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
-import javax.xml.bind.JAXBException;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
import java.io.IOException;
-import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -554,7 +554,6 @@ public class XMPPManager implements NotificationListener {
}
public ClientMessage incomingMessage(Message msg) {
- ClientMessage result = null;
if (msg.getType() != null && msg.getType().equals(Message.Type.ERROR)) {
StanzaError error = msg.getError();
if (error != null && error.getCondition().equals(Condition.RESOURCE_CONSTRAINT)) {
@@ -583,10 +582,10 @@ public class XMPPManager implements NotificationListener {
} catch (Exception e1) {
logger.warn("message exception", e1);
}
- } else {
- return ClientMessage.from(msg);
}
- return result;
+ ClientMessage errorMessage = ClientMessage.from(msg);
+ errorMessage.setError(new StanzaError(StanzaError.Type.CANCEL, Condition.ITEM_NOT_FOUND));
+ return errorMessage;
}
private ClientMessage incomingMessageJuick(User user_from, Jid from, String to, String command, @Nonnull URI attachment) {
if (StringUtils.isBlank(command) && attachment.toString().isEmpty()) {