aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-09-01 01:59:13 +0300
committerGravatar Vitaly Takmazov2018-09-01 01:59:13 +0300
commit2f4701110c5deff4d0f83d728ac15c98b965f3a8 (patch)
treec59a7fab36aa5d01d6a040b876f68c69468273f2 /juick-server/src/main/java/com
parent4f94886884b47e19f16da5b987ef1a740b29456e (diff)
fix message replies counters with banned users
Diffstat (limited to 'juick-server/src/main/java/com')
-rw-r--r--juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java3
1 files changed, 2 insertions, 1 deletions
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 c86e3736..a90cba55 100644
--- a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -791,7 +791,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
List<com.juick.Message> msgs = getNamedParameterJdbcTemplate().query(
"WITH RECURSIVE banned(message_id, reply_id) "
+ "AS (SELECT message_id, reply_id FROM replies WHERE replies.message_id IN (:ids) "
- + "AND EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :uid AND b.bl_user_id = replies.user_id) "
+ + "AND (EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :uid AND b.bl_user_id = replies.user_id) "
+ + "OR EXISTS (SELECT 1 from users u WHERE u.banned = 1 and u.id = replies.user_id and u.id <> :uid)) "
+ "UNION ALL SELECT replies.message_id, replies.reply_id FROM replies INNER JOIN banned "
+ "ON banned.reply_id = replies.replyto AND banned.message_id=replies.message_id "
+ "WHERE replies.message_id IN (:ids)) "