From 8a8683bc35583fed27b6562907a66bd171f8e778 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 2 Nov 2017 17:48:16 +0300 Subject: api: log raw telegram response --- .../src/main/java/com/juick/api/controllers/TelegramWebhook.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java b/juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java index 225e23ae..236e4064 100644 --- a/juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java +++ b/juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java @@ -29,6 +29,7 @@ import com.pengrad.telegrambot.model.PhotoSize; import com.pengrad.telegrambot.model.Update; import com.pengrad.telegrambot.request.GetFile; import com.pengrad.telegrambot.response.GetFileResponse; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,7 +74,9 @@ public class TelegramWebhook { @RequestMapping(value = "/tlgmbtwbhk", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void processUpdate(InputStream body) throws Exception { - Update update = BotUtils.parseUpdate(new InputStreamReader(body, StandardCharsets.UTF_8)); + String data = IOUtils.toString(body, StandardCharsets.UTF_8); + logger.info("got telegram msg: {}", data); + Update update = BotUtils.parseUpdate(data); Message message = update.message(); if (update.message() == null) { message = update.editedMessage(); @@ -82,8 +85,6 @@ public class TelegramWebhook { return; } } - - logger.info("got telegram msg {}", message); User user_from = usersService.getUserByUID(telegramService.getUser(message.chat().id())).orElse(new User()); logger.info("Found juick user {}", user_from.getUid()); -- cgit v1.2.3