diff options
author | Vitaly Takmazov | 2018-04-22 18:25:16 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-04-22 18:25:16 +0300 |
commit | e8041f3f4158a0cffd7403fec22272967475ddb7 (patch) | |
tree | da8175288f1215d9e1c7bda1f73e9fcc5f963868 /juick-server-jdbc/src/main/java/com/juick/service | |
parent | 58b625dc6a5c0276541d2ee76ae06312e9c3fb36 (diff) |
jdbc: do not show messages with banned tags in feeds
Diffstat (limited to 'juick-server-jdbc/src/main/java/com/juick/service')
-rw-r--r-- | juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java | 8 | ||||
-rw-r--r-- | juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java | 11 |
2 files changed, 8 insertions, 11 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java index 609b7e01..0ca30904 100644 --- a/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -51,6 +51,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Inject private UserService userService; @Inject + private TagService tagService; + @Inject private SearchService searchService; @Inject private ImagesService imagesService; @@ -443,6 +445,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ " OR m.user_id = :visitorUid) AND NOT EXISTS (" + " SELECT 1 FROM bl_users b WHERE b.user_id = :visitorUid AND b.bl_user_id = m.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 = m.message_id) and :visitorUid = bt.user_id)" + " AND NOT EXISTS (SELECT 1 from users u WHERE u.banned = 1 and u.id = m.user_id) ORDER BY m.message_id DESC LIMIT 20", sqlParameterSource, Integer.class); @@ -599,6 +603,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ (before > 0 ? " AND m.message_id < :before " : StringUtils.EMPTY) + " AND m.popular > 0 AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = m.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 = m.message_id) and :vid = bt.user_id)" + " ORDER BY m.message_id DESC LIMIT 20", sqlParameterSource, Integer.class); @@ -616,6 +622,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ (before > 0 ? " AND m.message_id < :before " : StringUtils.EMPTY) + " AND m.attach IS NOT NULL " + + " AND NOT EXISTS (SELECT 1 FROM bl_tags bt WHERE bt.tag_id IN " + + "(SELECT tag_id FROM messages_tags WHERE message_id = m.message_id) and :vid = bt.user_id)" + " AND NOT EXISTS (SELECT 1 from users u WHERE u.banned = 1 and u.id = m.user_id) " + " AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = m.user_id) " + " ORDER BY m.message_id DESC LIMIT 20", diff --git a/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java index 0e371ab5..880f18b9 100644 --- a/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java +++ b/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java @@ -28,16 +28,13 @@ import org.springframework.jdbc.support.GeneratedKeyHolder; import org.springframework.jdbc.support.KeyHolder; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.Assert; -import javax.inject.Inject; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.regex.Matcher; @@ -54,14 +51,6 @@ public class TagServiceImpl extends BaseJdbcService implements TagService { private static final Pattern TAGS_PATTERN2 = Pattern.compile("^\\*([^ \\r\\n\\t]+)[\\s+]?([\\s\\S]+)?"); private static final Pattern TAG_PATTERN = Pattern.compile("\\*([^ \\r\\n\\t]+)"); - private final MessagesService messagesService; - - @Inject - public TagServiceImpl(MessagesService messagesService) { - Assert.notNull(messagesService, "MessagesService must be initialized"); - this.messagesService = messagesService; - } - @Transactional(readOnly = true) @Override public com.juick.Tag getTag(final int tid) { |