diff options
author | 2018-05-10 12:50:08 +0300 | |
---|---|---|
committer | 2018-05-10 12:50:08 +0300 | |
commit | fb540605626e1c7bb1544a518a254e6a820afcb3 (patch) | |
tree | b370df3f031a1a72a34b64bc197cd600b6947f5d /juick-server/src/main/java/com/juick/server/TelegramBotManager.java | |
parent | d2a1f21717c8583c9804c69319123fb7ebaac261 (diff) |
server: MessageReadEvent
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/TelegramBotManager.java')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/TelegramBotManager.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java index a024bee6..a30b2bf3 100644 --- a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java +++ b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java @@ -18,10 +18,7 @@ package com.juick.server; import com.juick.User; -import com.juick.server.component.LikeEvent; -import com.juick.server.component.MessageEvent; -import com.juick.server.component.PingEvent; -import com.juick.server.component.SubscribeEvent; +import com.juick.server.component.*; import com.juick.server.helpers.CommandResult; import com.juick.server.util.HttpUtils; import com.juick.service.MessagesService; @@ -46,6 +43,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Component; import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponentsBuilder; @@ -80,6 +78,8 @@ public class TelegramBotManager implements NotificationListener { private UserService userService; @Inject private CommandsManager commandsManager; + @Inject + private ApplicationEventPublisher applicationEventPublisher; @Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}") private String tmpDir; @@ -302,6 +302,8 @@ public class TelegramBotManager implements NotificationListener { if (MessageUtils.isReply(source)) { messagesService.setLastReadComment(userService.getUserByUID(userId) .orElseThrow(IllegalStateException::new), source.getMid(), source.getRid()); + User user = userService.getUserByUID(userId).orElseThrow(IllegalStateException::new); + applicationEventPublisher.publishEvent(new MessageReadEvent(this, user, source)); } } } @@ -327,6 +329,9 @@ public class TelegramBotManager implements NotificationListener { public void processMessageEvent(MessageEvent messageEvent) { com.juick.Message jmsg = messageEvent.getMessage(); List<User> subscribedUsers = messageEvent.getUsers(); + if (jmsg.isService()) { + return; + } String msgUrl = formatUrl(jmsg); if (MessageUtils.isPM(jmsg)) { telegramService.getTelegramIdentifiers(Collections.singletonList(jmsg.getTo())) @@ -364,7 +369,12 @@ public class TelegramBotManager implements NotificationListener { } @Override - public void ProcessPingEvent(PingEvent pingEvent) { + public void processPingEvent(PingEvent pingEvent) { + + } + + @Override + public void processMessageReadEvent(MessageReadEvent messageReadEvent) { } |