diff options
author | Vitaly Takmazov | 2016-12-19 23:39:25 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-12-19 23:39:25 +0300 |
commit | 03a03639514bfb586555a3367fd3ea58da0f2a94 (patch) | |
tree | a8e62458bda9f0e99d5685b8e1c42a1a82226051 | |
parent | e8552c9b162daa5cf4e651330e278dee4ea5198f (diff) |
juick-server: fix tags in getSubscribedUsers
-rw-r--r-- | juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java | 6 | ||||
-rw-r--r-- | src/test/java/com/juick/tests/ApiTests.java | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java b/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java index 767c62fc..decfe59d 100644 --- a/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java @@ -58,14 +58,16 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip User author = messagesService.getMessageAuthor(mid); List<User> userids = userService.getUserReaders(uid); + List<Integer> tags = tagService.getMessageTagsIDs(mid); + List<String> tagsStr = tagService.getMessageTags(mid).stream().map(t -> t.getTag().getName()).collect(Collectors.toList()); Set<Integer> set = new HashSet<>(); set.addAll( userids.stream() - .map(User::getUid) + .map(User::getUid).filter(u -> Collections.disjoint(tagService.getUserBLTags(u), tagsStr)) .collect(Collectors.toList())); - List<Integer> tags = tagService.getMessageTagsIDs(mid); + if (!tags.isEmpty()) { List<Integer> tagUsers = getNamedParameterJdbcTemplate().queryForList( "SELECT st.suser_id FROM subscr_tags st " + diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java index 931838d7..6a945d4a 100644 --- a/src/test/java/com/juick/tests/ApiTests.java +++ b/src/test/java/com/juick/tests/ApiTests.java @@ -226,6 +226,10 @@ public class ApiTests { juickProtocol.getReply(user, "#" + mid + " *there").getResult()); assertEquals("number of tags should match", 2, tagService.getMessageTags(mid).size()); + assertEquals("should be blacklisted", "Tag added to your blacklist", + juickProtocol.getReply(readerUser, "BL *there").getResult()); + assertEquals("number of subscribed users should match", 0, + subscriptionService.getSubscribedUsers(uid, mid).size()); assertEquals("tags should be updated", "Tags are updated", juickProtocol.getReply(user, "#" + mid + " *there").getResult()); assertEquals("number of tags should match", 1, |