From ce3295d247c62a8ba1f0b31c4ddba0fed466bb3e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 9 Apr 2018 14:21:09 +0300 Subject: server: xmpp fixes --- .../src/main/java/com/juick/server/XMPPConnection.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java') diff --git a/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java index 7cdb7fcc..ab0271b0 100644 --- a/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java @@ -574,7 +574,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener { } } - public void incomingMessage(Message msg) throws Exception { + public void incomingMessage(Message msg) { User user_from; user_from = userService.getUserByJID(msg.getFrom().asBareJid().toEscapedString()); if (user_from == null) { @@ -625,8 +625,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener { } } } - private void incomingMessageJuick(User user_from, Jid from, String command, @Nonnull URI attachment) - throws Exception { + private void incomingMessageJuick(User user_from, Jid from, String command, @Nonnull URI attachment) { if (StringUtils.isBlank(command) && attachment.toString().isEmpty()) { return; } @@ -638,10 +637,15 @@ public class XMPPConnection implements StanzaListener, NotificationListener { command = command.substring(3); } - CommandResult result = commandsManager.processCommand(user_from, command.trim(), attachment); - if (StringUtils.isNotBlank(result.getText())) { - sendReply(from, result.getText()); + try { + CommandResult result = commandsManager.processCommand(user_from, command.trim(), attachment); + if (StringUtils.isNotBlank(result.getText())) { + sendReply(from, result.getText()); + } + } catch (Exception e) { + sendReply(from, "Error processing command"); } + } @Override @@ -653,7 +657,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener { } } else if (xmlValue instanceof Message) { Message msg = (Message) xmlValue; - router.send(msg); + incomingMessage(msg); } else if (xmlValue instanceof IQ) { IQ iq = (IQ) xmlValue; router.send(iq); -- cgit v1.2.3