aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/main/java/com/juick/api
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-12-05 10:08:33 +0300
committerGravatar Vitaly Takmazov2016-12-05 10:27:06 +0300
commit7e972fd8b43a645c18605024a3b992dd14b9dd19 (patch)
treed23857d12a1f2c1e88181351111f7fd3be5b661a /juick-api/src/main/java/com/juick/api
parent130dd6e711a4528cdb30fb1b1d60be9687970bc3 (diff)
juick-api: fix telegram update parsing
Diffstat (limited to 'juick-api/src/main/java/com/juick/api')
-rw-r--r--juick-api/src/main/java/com/juick/api/controllers/TelegramWebhook.java12
1 files changed, 9 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 60856ec6..059a6156 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
@@ -7,14 +7,19 @@ 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.codec.Charsets;
+import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
import java.util.List;
/**
@@ -32,8 +37,9 @@ public class TelegramWebhook {
@RequestMapping(value = "/tlgmbtwbhk", method = RequestMethod.POST)
- public void processUpdate(@RequestBody String updateData) {
- Update update = BotUtils.parseUpdate(updateData);
+ @ResponseStatus(value = HttpStatus.OK)
+ public void processUpdate(HttpServletRequest request) throws IOException {
+ Update update = BotUtils.parseUpdate(IOUtils.toString(request.getInputStream(), Charsets.UTF_8));
Message message = update.message();
if (update.message() == null) {
message = update.editedMessage();