From 90d77f71c53a6349c1fb3bcf81d6f9a2a630b3e6 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 16 Apr 2018 17:17:03 +0300 Subject: server: mark comments from blacklisted users as read --- juick-server/src/main/java/com/juick/server/ServerManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'juick-server/src/main/java/com/juick/server') diff --git a/juick-server/src/main/java/com/juick/server/ServerManager.java b/juick-server/src/main/java/com/juick/server/ServerManager.java index f209d934..3db6ec90 100644 --- a/juick-server/src/main/java/com/juick/server/ServerManager.java +++ b/juick-server/src/main/java/com/juick/server/ServerManager.java @@ -18,10 +18,12 @@ package com.juick.server; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.juick.Message; import com.juick.User; import com.juick.server.component.MessageEvent; import com.juick.service.MessagesService; import com.juick.service.SubscriptionService; +import com.juick.service.UserService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -48,6 +50,10 @@ public class ServerManager implements ApplicationListener { private MessagesService messagesService; @Inject private WebsocketManager wsHandler; + @Inject + private SubscriptionService subscriptionService; + @Inject + private UserService userService; @Value("${service_user:juick}") private String serviceUser; @Inject @@ -157,7 +163,11 @@ public class ServerManager implements ApplicationListener { onJuickMessagePost(messagesService.getMessage(jmsg.getMid()), subscribedUsers); } else { // to get quote and attachment + Message op = messagesService.getMessage(jmsg.getMid()); com.juick.Message reply = messagesService.getReply(jmsg.getMid(), jmsg.getRid()); + subscriptionService.getUsersSubscribedToComments(op, reply, true).stream() + .filter(u -> userService.isInBLAny(reply.getUser().getUid(), u.getUid())) + .forEach(b -> messagesService.setLastReadComment(b, reply.getMid(), reply.getRid())); onJuickMessageReply(reply, subscribedUsers); } } -- cgit v1.2.3