From 77c7232a3ca354e009dfdd5a5eb0d390d7e627f5 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 21 Mar 2018 15:39:19 +0300 Subject: xmpp: do not post commands --- .../src/main/java/com/juick/server/XMPPBot.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'juick-server/src/main/java') diff --git a/juick-server/src/main/java/com/juick/server/XMPPBot.java b/juick-server/src/main/java/com/juick/server/XMPPBot.java index 29637032..c29fa188 100644 --- a/juick-server/src/main/java/com/juick/server/XMPPBot.java +++ b/juick-server/src/main/java/com/juick/server/XMPPBot.java @@ -337,13 +337,16 @@ public class XMPPBot implements StanzaListener, AutoCloseable { } Optional result = processCommand(user_from, msg.getFrom(), command); - result.ifPresent(r -> sendReply(msg.getFrom(), r)); - // new message - List tags = tagService.fromString(command, false); - String body = command.substring(TagUtils.toString(tags).length()); - int mid = messagesService.createMessage(user_from.getUid(), body, null, tags); - subscriptionService.subscribeMessage(mid, user_from.getUid()); - applicationEventPublisher.publishEvent(new MessageEvent(this, messagesService.getMessage(mid))); + if (result.isPresent()) { + sendReply(msg.getFrom(), result.get()); + } else { + // new message + List tags = tagService.fromString(command, false); + String body = command.substring(TagUtils.toString(tags).length()); + int mid = messagesService.createMessage(user_from.getUid(), body, null, tags); + subscriptionService.subscribeMessage(mid, user_from.getUid()); + applicationEventPublisher.publishEvent(new MessageEvent(this, messagesService.getMessage(mid))); + } return true; } -- cgit v1.2.3