aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java8
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java4
2 files changed, 9 insertions, 3 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"
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index ff86f4b4..aceed0b9 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -1178,9 +1178,11 @@ public class ServerTests {
assertThat(nonblmsgs.get(0).getReplies(), is(5));
commandsManager.processCommand(ugnich, "BL @freefd", emptyUri);
Tag tag = tagService.getTag("linux", true);
- messagesService.createMessage(freefd.getUid(), "sux", null, Collections.singletonList(tag));
+ int freefdMsg = messagesService.createMessage(freefd.getUid(), "sux", null, Collections.singletonList(tag));
assertThat(messagesService.getTag(tag.TID, freefd.getUid(), 0, 10).size(), is(1));
assertThat(messagesService.getTag(tag.TID, ugnich.getUid(), 0, 10).size(), is(0));
+ messagesService.recommendMessage(freefdMsg, serviceUser.getUid());
+ assertThat(messagesService.getUserBlogWithRecommendations(serviceUser, ugnich, 0, 0).contains(freefdMsg), is(false));
commandsManager.processCommand(ugnich, "BL @freefd", emptyUri);
}