aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick')
-rw-r--r--juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java14
1 files changed, 11 insertions, 3 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 35e48383..d68ef8dd 100644
--- a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -837,7 +837,13 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Override
public List<Message> getReplies(final User user, final int mid) {
List<Message> replies = getNamedParameterJdbcTemplate().query(
- "SELECT replies.message_id as mid, replies.reply_id, replies.replyto, " +
+ "WITH RECURSIVE banned(reply_id, user_id) AS (" +
+ "SELECT reply_id, user_id FROM replies " +
+ "WHERE replies.message_id = :mid " +
+ "AND EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :uid AND b.bl_user_id = replies.user_id) " +
+ "UNION ALL SELECT replies.reply_id, replies.user_id FROM replies " +
+ "INNER JOIN banned ON banned.reply_id = replies.replyto ) " +
+ "SELECT replies.message_id as mid, replies.reply_id, replies.replyto, " +
"replies.user_id, users.nick, users.banned, " +
"replies.ts, " +
"0 as readonly, 0 as privacy, 0 as replies, " +
@@ -853,8 +859,10 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
"LEFT JOIN messages m on replies.message_id = m.message_id " +
"LEFT JOIN users qu ON qw.user_id=qu.id " +
"LEFT JOIN users mu ON m.user_id=mu.id " +
- "WHERE replies.message_id = :mid ORDER BY replies.reply_id ASC",
- new MapSqlParameterSource("mid", mid),
+ "WHERE replies.message_id = :mid " +
+ "AND NOT EXISTS (SELECT 1 FROM banned WHERE banned.reply_id = replies.reply_id) " +
+ "ORDER BY replies.reply_id ASC",
+ new MapSqlParameterSource("mid", mid).addValue("uid", user.getUid()),
new MessageMapper());
if (replies.size() > 0) {
setLastReadComment(user, mid, replies.stream().map(Message::getRid).max(Comparator.naturalOrder()).get());