From a5f045a3780ef8530afa7493cf090771b8fdcfe1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 3 Apr 2018 17:55:46 +0300 Subject: refactoring: all messages are processed with XMPPConnection --- .../src/main/java/com/juick/server/TelegramBotManager.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'juick-server/src/main/java/com/juick/server/TelegramBotManager.java') diff --git a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java index 020d2433..320ab9ae 100644 --- a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java +++ b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java @@ -53,6 +53,7 @@ import org.springframework.web.util.UriComponentsBuilder; import javax.annotation.PostConstruct; import javax.inject.Inject; import java.io.IOException; +import java.net.URI; import java.net.URL; import java.util.*; @@ -129,7 +130,7 @@ public class TelegramBotManager implements NotificationListener { if (user_from.getUid() == 0) { telegramSignupNotify(message.from().id().longValue(), userService.getSignUpHashByTelegramID(message.from().id().longValue(), username)); } else { - String attachment = StringUtils.EMPTY; + URI attachment = URI.create(StringUtils.EMPTY); if (message.photo() != null) { String fileId = Arrays.stream(message.photo()).max(Comparator.comparingInt(PhotoSize::fileSize)) .orElse(new PhotoSize()).fileId(); @@ -149,7 +150,7 @@ public class TelegramBotManager implements NotificationListener { if (StringUtils.isBlank(text)) { text = StringUtils.EMPTY; } - if (StringUtils.isNotEmpty(text) || StringUtils.isNotEmpty(attachment)) { + if (StringUtils.isNotEmpty(text) || StringUtils.isNotEmpty(attachment.toString())) { if (text.equalsIgnoreCase("LOGIN") || text.equalsIgnoreCase("PING") || text.equalsIgnoreCase("HELP") @@ -183,7 +184,7 @@ public class TelegramBotManager implements NotificationListener { int rid = Integer.valueOf(uriComponents.getFragment()); prefix = String.format("#%d/%d ", mid, rid); } - xmppConnection.processMessage(user_from, prefix + text, attachment); + xmppConnection.incomingMessageJuick(user_from, null,prefix + text, attachment); telegramNotify(message.from().id().longValue(), "Reply sent", StringUtils.EMPTY); } else { logger.warn("invalid path: {}", path); @@ -200,7 +201,7 @@ public class TelegramBotManager implements NotificationListener { "Can not reply to this message", replyMessage.messageId(), StringUtils.EMPTY); } } else { - xmppConnection.processMessage(user_from, text, attachment); + xmppConnection.incomingMessageJuick(user_from, null, text, attachment); telegramNotify(message.from().id().longValue(), "Message sent", StringUtils.EMPTY); } } -- cgit v1.2.3