diff options
author | Vitaly Takmazov | 2017-09-22 17:36:01 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-09-22 17:36:01 +0300 |
commit | d749fdee3a3df14e25a4864ec2cf72038c3b091d (patch) | |
tree | b7cfc9318012baf3fb43b5c2027224ccef71f0cd /juick-api/src/main | |
parent | c4c26f3d61dd790dbb2ca9965eb0cd134c59e29c (diff) |
api: inject correct json mapper
Diffstat (limited to 'juick-api/src/main')
-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) { |