aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/api
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-08-14 21:31:09 +0300
committerGravatar Vitaly Takmazov2018-08-14 21:50:39 +0300
commitd521327847864742286ca50207d73454006cd792 (patch)
tree1b0fce683b0f9de242c50bb82178abfe3038c2d3 /juick-server/src/main/java/com/juick/server/api
parent2c1bfab10903895ece9644bc095597aaef2a75e8 (diff)
Telegram: debug mode without webhook
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/api')
-rw-r--r--juick-server/src/main/java/com/juick/server/api/webhooks/TelegramWebhook.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/juick-server/src/main/java/com/juick/server/api/webhooks/TelegramWebhook.java b/juick-server/src/main/java/com/juick/server/api/webhooks/TelegramWebhook.java
index 10fd1ab3..8497cff1 100644
--- a/juick-server/src/main/java/com/juick/server/api/webhooks/TelegramWebhook.java
+++ b/juick-server/src/main/java/com/juick/server/api/webhooks/TelegramWebhook.java
@@ -18,7 +18,11 @@
package com.juick.server.api.webhooks;
import com.juick.server.TelegramBotManager;
+import com.pengrad.telegrambot.BotUtils;
+import com.pengrad.telegrambot.model.Update;
import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -36,8 +40,9 @@ import java.nio.charset.StandardCharsets;
*/
@ApiIgnore
@RestController
-@ConditionalOnProperty(name = "telegram_token")
+@ConditionalOnProperty({"telegram_token", "telegram_debug"})
public class TelegramWebhook {
+ private static final Logger logger = LoggerFactory.getLogger(TelegramWebhook.class);
@Inject
private TelegramBotManager telegramBotManager;
@@ -45,6 +50,8 @@ public class TelegramWebhook {
@ResponseStatus(value = HttpStatus.OK)
public void processUpdate(InputStream body) throws Exception {
String data = IOUtils.toString(body, StandardCharsets.UTF_8);
- telegramBotManager.processUpdate(data);
+ logger.info("Telegram update: {}", data);
+ Update update = BotUtils.parseUpdate(data);
+ telegramBotManager.processUpdate(update);
}
}