diff options
author | Vitaly Takmazov | 2017-10-11 12:47:02 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-10-11 12:47:02 +0300 |
commit | 753d79d6bbabfdac33c6c382717fe0acaec2a3bd (patch) | |
tree | 006a2b957d4a599315d1472ae1d4f7e726136ee2 /juick-api/src/main/java/com/juick | |
parent | 0ad4b98456e5de96a9fea6e128a20a4624c72c6a (diff) |
telegram: do not duplicate subscription requests
Diffstat (limited to 'juick-api/src/main/java/com/juick')
-rw-r--r-- | juick-api/src/main/java/com/juick/api/TelegramBotManager.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/juick-api/src/main/java/com/juick/api/TelegramBotManager.java b/juick-api/src/main/java/com/juick/api/TelegramBotManager.java index 161680e9..4de5c840 100644 --- a/juick-api/src/main/java/com/juick/api/TelegramBotManager.java +++ b/juick-api/src/main/java/com/juick/api/TelegramBotManager.java @@ -19,6 +19,7 @@ package com.juick.api; import com.fasterxml.jackson.databind.ObjectMapper; import com.juick.service.MessagesService; +import com.juick.service.SubscriptionService; import com.juick.service.TelegramService; import com.pengrad.telegrambot.Callback; import com.pengrad.telegrambot.TelegramBot; @@ -64,6 +65,8 @@ public class TelegramBotManager extends TextWebSocketHandler { @Inject private MessagesService messagesService; @Inject + private SubscriptionService subscriptionService; + @Inject private ObjectMapper jsonMapper; private WebSocketSession session; @@ -115,7 +118,7 @@ public class TelegramBotManager extends TextWebSocketHandler { if (jmsg.getRid() == 0) { String msg = formatPost(jmsg); - List<Long> users = telegramService.getSubscribers(jmsg.getUser().getUid()); + List<Long> users = telegramService.getTelegramIdentifiers(subscriptionService.getSubscribedUsers(jmsg.getUser().getUid(), jmsg.getMid())); List<Long> chats = telegramService.getChats(); // registered subscribed users @@ -126,7 +129,9 @@ public class TelegramBotManager extends TextWebSocketHandler { // get quote com.juick.Message msg = messagesService.getReply(jmsg.getMid(), jmsg.getRid()); String fmsg = formatPost(msg); - telegramService.getSubscribersToComments(jmsg.getMid(), jmsg.getUser().getUid()).forEach(c -> telegramNotify(c, fmsg, msgUrl)); + telegramService.getTelegramIdentifiers( + subscriptionService.getUsersSubscribedToComments(jmsg.getMid(), jmsg.getUser().getUid()) + ).forEach(c -> telegramNotify(c, fmsg, msgUrl)); } } |