aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index 0625716a..b14e9261 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -698,8 +698,12 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
.addValue("privacy", privacy).addValue("before", before);
return getNamedParameterJdbcTemplate()
- .queryForList("SELECT message_id FROM " + "(SELECT message_id FROM favorites " + " INNER JOIN users"
- + " ON favorites.user_id = users.id" + " WHERE user_id = :uid AND users.banned = 0"
+ .queryForList("SELECT message_id FROM " + "(SELECT favorites.message_id FROM favorites "
+ + " INNER JOIN messages ON messages.message_id = favorites.message_id"
+ + " INNER JOIN users ON messages.user_id = users.id" + " WHERE favorites.user_id = :uid AND users.banned = 0"
+ + " AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = messages.user_id) "
+ + " AND NOT EXISTS (SELECT 1 FROM bl_tags bt WHERE bt.tag_id IN "
+ + "(SELECT tag_id FROM messages_tags WHERE message_id = favorites.message_id) and :vid = bt.user_id)"
+ (before > 0 ? " AND message_id < :before " : StringUtils.EMPTY)
+ " ORDER BY message_id DESC LIMIT 20) as r" + " UNION ALL " + "SELECT message_id FROM "
+ "(SELECT message_id FROM messages" + " INNER JOIN users" + " ON messages.user_id = users.id"