From 835482fba474cae7b9bdc714f4552f669458482b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 5 Sep 2017 14:08:59 +0300 Subject: api: parse telegram update from stream --- .../src/main/java/com/juick/api/controllers/TelegramWebhook.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'juick-api/src/main') 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 dc10ceba..4496f6a3 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 @@ -24,7 +24,6 @@ import com.juick.service.UserService; import com.pengrad.telegrambot.BotUtils; import com.pengrad.telegrambot.model.Message; import com.pengrad.telegrambot.model.Update; -import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; @@ -36,6 +35,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.inject.Inject; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.List; @@ -56,7 +56,7 @@ public class TelegramWebhook { @RequestMapping(value = "/tlgmbtwbhk", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void processUpdate(InputStream body) throws IOException { - Update update = BotUtils.parseUpdate(IOUtils.toString(body, StandardCharsets.UTF_8)); + Update update = BotUtils.parseUpdate(new InputStreamReader(body, StandardCharsets.UTF_8)); Message message = update.message(); if (update.message() == null) { message = update.editedMessage(); -- cgit v1.2.3