diff options
Diffstat (limited to 'juick-api')
-rw-r--r-- | juick-api/src/main/java/com/juick/api/TGBot.java | 11 |
1 files changed, 4 insertions, 7 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 72097154..aa912b29 100644 --- a/juick-api/src/main/java/com/juick/api/TGBot.java +++ b/juick-api/src/main/java/com/juick/api/TGBot.java @@ -58,7 +58,6 @@ public class TGBot extends TextWebSocketHandler { private static final Logger logger = LoggerFactory.getLogger(TGBot.class); private TelegramBot bot; - private ObjectMapper ms; @Value("${telegram_token}") private String telegramToken; @@ -68,6 +67,8 @@ public class TGBot extends TextWebSocketHandler { private MessagesService messagesService; @Inject static WebSocketConnectionManager connectionManager; + @Inject + private ObjectMapper jsonMapper; private WebSocketSession session; @@ -78,10 +79,6 @@ public class TGBot extends TextWebSocketHandler { return; } bot = TelegramBotAdapter.build(telegramToken); - ms = new ObjectMapper(); - ms.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); - ms.setSerializationInclusion(JsonInclude.Include.NON_NULL); - ms.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); try { SetWebhook webhook = new SetWebhook().url("https://api.juick.com/tlgmbtwbhk"); if (!bot.execute(webhook).isOk()) { @@ -114,10 +111,10 @@ public class TGBot extends TextWebSocketHandler { @Override protected void handleTextMessage(WebSocketSession session, TextMessage text) throws Exception { - com.juick.Message jmsg = ms.readValue(text.asBytes(), com.juick.Message.class); + com.juick.Message jmsg = jsonMapper.readValue(text.asBytes(), com.juick.Message.class); if (logger.isInfoEnabled()) // prevent writeValueAsString execution if logger disabled - logger.info("got jmsg: {}", ms.writeValueAsString(jmsg)); + logger.info("got jmsg: {}", jsonMapper.writeValueAsString(jmsg)); String msgUrl = formatUrl(jmsg); if (jmsg.getRid() == 0) { |