diff options
author | 2018-04-03 17:55:46 +0300 | |
---|---|---|
committer | 2018-04-03 17:55:54 +0300 | |
commit | a5f045a3780ef8530afa7493cf090771b8fdcfe1 (patch) | |
tree | 56e4cbc6949dc9bd39672ccf379324338f0eef76 /juick-server/src/main/java/com/juick/server/TelegramBotManager.java | |
parent | c53675e5eb19a1a05ae5edcd0322075d51628b96 (diff) |
refactoring: all messages are processed with XMPPConnection
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/TelegramBotManager.java')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/TelegramBotManager.java | 9 |
1 files changed, 5 insertions, 4 deletions
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); } } |