From ea412bd40ab3576ac752c30705a13c0a7dfac27b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 4 Jul 2018 17:53:09 +0300 Subject: do not show notifications from banned threads --- .../src/main/java/com/juick/service/MessagesServiceImpl.java | 1 + .../src/main/java/com/juick/service/SubscriptionServiceImpl.java | 6 +++--- juick-server/src/main/java/com/juick/service/UserServiceImpl.java | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'juick-server/src/main/java/com/juick') diff --git a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java index 6c13190f..d64ecc04 100644 --- a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -862,6 +862,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ "LEFT JOIN users mu ON m.user_id=mu.id " + "WHERE replies.message_id = :mid " + "AND NOT EXISTS (SELECT 1 FROM banned WHERE banned.reply_id = replies.reply_id) " + + "AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :uid AND b.bl_user_id = m.user_id) " + "ORDER BY replies.reply_id ASC", new MapSqlParameterSource("mid", mid).addValue("uid", user.getUid()), new MessageMapper()); diff --git a/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java b/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java index b97fc0a4..c567b5cd 100644 --- a/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java @@ -106,9 +106,9 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip msg.getMid(), reply.getUser().getUid()); if (!userids.isEmpty()) { - return userService.getUsersByID(userids.stream() - .filter(u -> blacklisted || !userService.isInBLAny(u, reply.getUser().getUid())) - .collect(Collectors.toList())); + return userService.getUsersByID(userids).stream() + .filter(u -> blacklisted || !userService.isReplyToBL(u, reply)) + .collect(Collectors.toList()); } return Collections.emptyList(); } diff --git a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java index bc448151..050fc281 100644 --- a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java @@ -461,9 +461,12 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { "INNER JOIN banned ON banned.reply_id = replies.replyto " + "WHERE replies.message_id = :mid) " + "SELECT COUNT(reply_id) from replies " + + "INNER JOIN messages m ON m.message_id = replies.message_id " + "WHERE replies.message_id = :mid " + "AND replies.reply_id = :rid " + - "AND EXISTS (SELECT 1 FROM banned WHERE banned.reply_id = replies.reply_id) ", + "AND (EXISTS (SELECT 1 FROM banned WHERE banned.reply_id = replies.reply_id) " + + "OR EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :uid AND b.bl_user_id = m.user_id)" + + "OR EXISTS (SELECT 1 FROM bl_users b WHERE b.bl_user_id = :uid AND b.user_id = m.user_id))", new MapSqlParameterSource("uid", user.getUid()) .addValue("mid", reply.getMid()) .addValue("rid", reply.getRid()), -- cgit v1.2.3