aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-07-07 10:22:01 +0300
committerGravatar Vitaly Takmazov2016-07-07 10:22:01 +0300
commita0d038f5e6aa28ef67162c591abe64d057a19fa5 (patch)
tree4c67a7d1b9d7b44e9e0e14f904533bb175ed8579 /src
parenta732644480ff8b5b2ee46124af4d8c62944e39eb (diff)
filter top and photos by bl_users
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/server/MessagesQueries.java14
1 files 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<Integer> getPopular(JdbcTemplate sql, int before) {
+ public static List<Integer> getPopular(JdbcTemplate sql, int visitor_uid, int before) {
if (before > 0) {
return sql.queryForList("SELECT message_id FROM messages WHERE message_id<? AND privacy>0 " +
- "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_id<? AND (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[]{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);
}
}