aboutsummaryrefslogtreecommitdiff
path: root/juick-server
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server')
-rw-r--r--juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java3
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java3
2 files changed, 5 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)) "
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index c6d1bc1a..b5f5143b 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -1317,6 +1317,9 @@ public class ServerTests {
int bannedRid = messagesService.createReply(mid, 0, banned, "KURWA", null);
int casualRid = messagesService.createReply(mid, 0, userService.getUserByName("user"), "DOOR", null);
assertThat(messagesService.getReplies(AnonymousUser.INSTANCE, mid).size(), is(1));
+ assertThat(messagesService.getMessages(AnonymousUser.INSTANCE, Collections.singletonList(mid)).get(0).getReplies(), is(1));
assertThat(messagesService.getReplies(banned, mid).size(), is(2));
+ assertThat(messagesService.getMessages(banned, Collections.singletonList(mid)).get(0).getReplies(), is(2));
+
}
}