diff options
author | Vitaly Takmazov | 2018-07-04 12:46:42 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-07-04 12:46:42 +0300 |
commit | 593b0bff6ddd6ff3756d7ee46d44defb12b0e982 (patch) | |
tree | cc4843077cfbdc2df8b1d07d8232f158dd2e3450 /juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java | |
parent | 2e6c77c1db5b1017c8701c3b016c62d3b100fd64 (diff) |
do not show banned users in thread
Diffstat (limited to 'juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java')
-rw-r--r-- | juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java | 14 |
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()); |