aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'juick-api/src/main')
-rw-r--r--juick-api/src/main/java/com/juick/api/TGBot.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/juick-api/src/main/java/com/juick/api/TGBot.java b/juick-api/src/main/java/com/juick/api/TGBot.java
index ae3c6b74..882dc821 100644
--- a/juick-api/src/main/java/com/juick/api/TGBot.java
+++ b/juick-api/src/main/java/com/juick/api/TGBot.java
@@ -1,6 +1,6 @@
package com.juick.api;
-import com.juick.json.MessageSerializer;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.service.MessagesService;
import com.juick.service.TelegramService;
import com.neovisionaries.ws.client.WebSocket;
@@ -16,7 +16,6 @@ import com.pengrad.telegrambot.request.SendMessage;
import com.pengrad.telegrambot.request.SetWebhook;
import com.pengrad.telegrambot.response.SendResponse;
import org.apache.commons.lang3.StringUtils;
-import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,7 +35,7 @@ public class TGBot implements AutoCloseable {
TelegramBot bot;
WebSocket ws;
- MessageSerializer ms = new MessageSerializer();
+ ObjectMapper ms = new ObjectMapper();
@Inject
TelegramService telegramService;
@@ -71,8 +70,8 @@ public class TGBot implements AutoCloseable {
@Override
public void onTextMessage(WebSocket websocket, String text) throws Exception {
super.onTextMessage(websocket, text);
- com.juick.Message jmsg = ms.deserialize(new JSONObject(text));
- logger.info("got jmsg: " + ms.serialize(jmsg).toString());
+ com.juick.Message jmsg = ms.readValue(text, com.juick.Message.class);
+ logger.info("got jmsg: " + ms.writeValueAsString(jmsg));
String msgUrl = formatUrl(jmsg);
if (jmsg.getRid() == 0) {
String msg = formatPost(jmsg);