From a0d038f5e6aa28ef67162c591abe64d057a19fa5 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 7 Jul 2016 10:22:01 +0300 Subject: filter top and photos by bl_users --- src/main/java/com/juick/server/MessagesQueries.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/juick/server/MessagesQueries.java b/src/main/java/com/juick/server/MessagesQueries.java index 880e94e2..a0242543 100644 --- a/src/main/java/com/juick/server/MessagesQueries.java +++ b/src/main/java/com/juick/server/MessagesQueries.java @@ -446,14 +446,16 @@ public class MessagesQueries { } } - public static List getPopular(JdbcTemplate sql, int before) { + public static List getPopular(JdbcTemplate sql, int visitor_uid, int before) { if (before > 0) { return sql.queryForList("SELECT message_id FROM messages WHERE message_id0 " + - "AND popular>0 ORDER BY message_id DESC LIMIT 20", Integer.class, before); + "AND popular>0 AND user_id NOT IN (SELECT bl_user_id FROM bl_users WHERE user_id=?) " + + "ORDER BY message_id DESC LIMIT 20", Integer.class, before, visitor_uid); } else { return sql.queryForList("SELECT message_id FROM messages WHERE privacy>0 " + - "AND popular>0 ORDER BY message_id DESC LIMIT 20", Integer.class); + "AND popular>0 AND user_id NOT IN (SELECT bl_user_id FROM bl_users WHERE user_id=?) " + + "ORDER BY message_id DESC LIMIT 20", Integer.class, visitor_uid); } } @@ -461,11 +463,13 @@ public class MessagesQueries { if (before > 0) { return sql.queryForList("SELECT message_id FROM messages WHERE message_id0 OR user_id=?) " + "AND attach IS NOT NULL AND user_id NOT IN (SELECT id from users WHERE banned=1) " + - "ORDER BY message_id DESC LIMIT 20", new Object[]{before, visitor_uid}, Integer.class); + "AND user_id NOT IN (SELECT bl_user_id FROM bl_users WHERE user_id=?) " + + "ORDER BY message_id DESC LIMIT 20", Integer.class, before, visitor_uid, visitor_uid); } else { return sql.queryForList("SELECT message_id FROM messages WHERE (privacy>0 OR user_id=?) " + "AND attach IS NOT NULL AND user_id NOT IN (SELECT id from users WHERE banned=1) " + - "ORDER BY message_id DESC LIMIT 20", new Object[]{visitor_uid}, Integer.class); + "AND user_id NOT IN (SELECT bl_user_id FROM bl_users WHERE user_id=?) " + + "ORDER BY message_id DESC LIMIT 20", Integer.class, visitor_uid, visitor_uid); } } -- cgit v1.2.3