aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-common/src/main/java/com/juick/server/CommandsManager.java2
-rw-r--r--juick-common/src/main/java/com/juick/service/SubscriptionService.java2
-rw-r--r--juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java8
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java19
4 files changed, 17 insertions, 14 deletions
diff --git a/juick-common/src/main/java/com/juick/server/CommandsManager.java b/juick-common/src/main/java/com/juick/server/CommandsManager.java
index 5c034ce3..58c07255 100644
--- a/juick-common/src/main/java/com/juick/server/CommandsManager.java
+++ b/juick-common/src/main/java/com/juick/server/CommandsManager.java
@@ -298,7 +298,7 @@ public class CommandsManager {
case Added:
applicationEventPublisher.publishEvent(new LikeEvent(this, user, msg,
subscriptionService.getUsersSubscribedToUserRecommendations(
- user.getUid(), msg.getMid(), msg.getUser().getUid())));
+ user.getUid(), msg)));
return CommandResult.fromString("Message is added to your recommendations");
case Deleted:
return CommandResult.fromString("Message deleted from your recommendations.");
diff --git a/juick-common/src/main/java/com/juick/service/SubscriptionService.java b/juick-common/src/main/java/com/juick/service/SubscriptionService.java
index c726e68d..d2ff9962 100644
--- a/juick-common/src/main/java/com/juick/service/SubscriptionService.java
+++ b/juick-common/src/main/java/com/juick/service/SubscriptionService.java
@@ -36,7 +36,7 @@ public interface SubscriptionService {
List<User> getUsersSubscribedToComments(Message msg, Message reply, boolean blacklisted);
- List<User> getUsersSubscribedToUserRecommendations(int uid, int mid, int muid);
+ List<User> getUsersSubscribedToUserRecommendations(int uid, Message msg);
boolean subscribeMessage(Message message, User user);
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 e8c32e77..1dee379f 100644
--- a/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/SubscriptionServiceImpl.java
@@ -113,12 +113,12 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
}
@Override
- public List<User> getUsersSubscribedToUserRecommendations(final int uid, final int mid, final int muid) {
- Message msg = messagesService.getMessage(mid);
- List<String> msgTags = tagService.getMessageTags(mid).stream().map(t -> t.getTag().getName()).collect(Collectors.toList());
+ public List<User> getUsersSubscribedToUserRecommendations(final int uid, final Message msg) {
+ List<String> msgTags = tagService.getMessageTags(msg.getMid()).stream().map(t -> t.getTag().getName()).collect(Collectors.toList());
if (msg.getLikes() == 1) {
return userService.getUserReaders(uid).stream()
- .filter(u -> !userService.isInBLAny(u.getUid(), muid))
+ .filter(u -> !u.equals(msg.getUser()))
+ .filter(u -> !userService.isInBLAny(u.getUid(), msg.getUser().getUid()))
.filter(u -> Collections.disjoint(tagService.getUserBLTags(u.getUid()), msgTags))
.collect(Collectors.toList());
}
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index 646e1443..297a3c88 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -1183,21 +1183,24 @@ public class ServerTests {
Tag sampleTag = tagService.getTag("banned", true);
int posterMid = messagesService.createMessage(posterId, "YO", null, Collections.singletonList(sampleTag));
messagesService.recommendMessage(posterMid, recommenderId);
- BiFunction<Integer, Integer, List<User>> subscribers = (recommId, msgId) ->
- subscriptionService.getUsersSubscribedToUserRecommendations(recommId, msgId, posterId);
- List<User> recommendSubscribers = subscribers.apply(recommenderId, posterMid);
+ BiFunction<Integer, Message, List<User>> subscribers = (recommId, msg) ->
+ subscriptionService.getUsersSubscribedToUserRecommendations(recommId, msg);
+ List<User> recommendSubscribers = subscribers.apply(recommenderId, messagesService.getMessage(posterMid));
assertThat(recommendSubscribers.size(), is(1));
assertThat(recommendSubscribers.get(0).getUid(), is(readerId));
privacyQueriesService.blacklistUser(reader, poster);
- assertThat(subscribers.apply(recommenderId, posterMid).size(), is(0));
+ assertThat(subscribers.apply(recommenderId, messagesService.getMessage(posterMid)).size(), is(0));
privacyQueriesService.blacklistUser(reader, poster);
- assertThat(subscribers.apply(recommenderId, posterMid).size(), is(1));
+ assertThat(subscribers.apply(recommenderId, messagesService.getMessage(posterMid)).size(), is(1));
tagService.blacklistTag(reader, sampleTag);
- assertThat(subscribers.apply(recommenderId, posterMid).size(), is(0));
+ assertThat(subscribers.apply(recommenderId, messagesService.getMessage(posterMid)).size(), is(0));
tagService.blacklistTag(reader, sampleTag);
- assertThat(subscribers.apply(recommenderId, posterMid).size(), is(1));
+ assertThat(subscribers.apply(recommenderId, messagesService.getMessage(posterMid)).size(), is(1));
messagesService.recommendMessage(posterMid, lateRecommenderId);
- List<User> lateRecommendSubscribers = subscribers.apply(recommenderId, posterMid);
+ List<User> lateRecommendSubscribers = subscribers.apply(recommenderId, messagesService.getMessage(posterMid));
assertThat(lateRecommendSubscribers.size(), is(0));
+ int readerMid = messagesService.createMessage(readerId, "PEOPLE", null, null);
+ messagesService.recommendMessage(readerMid, recommenderId);
+ assertThat(subscribers.apply(recommenderId, messagesService.getMessage(readerMid)).size(), is(0));
}
}