diff options
author | Vitaly Takmazov | 2021-10-21 23:41:15 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2021-10-21 23:41:15 +0300 |
commit | 37f643b3466307e0b29b105df23b585108c7c564 (patch) | |
tree | 6ef5b32506e996c75ff6d6583725b2f2fb4c7852 /src/main | |
parent | c6972c05dcee19afb5725767f755a56f5162aee2 (diff) |
Top feed should not contain banned users
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/juick/service/MessagesServiceImpl.java | 8 |
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" |