aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server-jdbc/src')
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/SubscriptionServiceImpl.java14
-rw-r--r--juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java5
2 files changed, 13 insertions, 6 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/SubscriptionServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/SubscriptionServiceImpl.java
index eb3f79a9..77735b0c 100644
--- a/juick-server-jdbc/src/main/java/com/juick/service/SubscriptionServiceImpl.java
+++ b/juick-server-jdbc/src/main/java/com/juick/service/SubscriptionServiceImpl.java
@@ -17,6 +17,7 @@
package com.juick.service;
+import com.juick.Message;
import com.juick.Tag;
import com.juick.User;
import com.juick.server.helpers.NotifyOpts;
@@ -27,6 +28,7 @@ import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
+import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.util.Collections;
import java.util.HashSet;
@@ -102,15 +104,17 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip
@Transactional(readOnly = true)
@Override
- public List<User> getUsersSubscribedToComments(final int mid, final int ignore_uid) {
+ public List<User> getUsersSubscribedToComments(@Nonnull final Message msg, @Nonnull final Message reply) {
List<Integer> userids = getJdbcTemplate().queryForList(
"SELECT suser_id FROM subscr_messages WHERE message_id=? AND suser_id!=?",
Integer.class,
- mid, ignore_uid);
-
- if (!userids.isEmpty())
- return userService.getUsersByID(userids);
+ msg.getMid(), reply.getUser().getUid());
+ if (!userids.isEmpty()) {
+ return userService.getUsersByID(userids.stream()
+ .filter(u -> !userService.isInBLAny(u, reply.getUser().getUid()))
+ .collect(Collectors.toList()));
+ }
return Collections.emptyList();
}
diff --git a/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java b/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java
index 4ef06789..57e0970a 100644
--- a/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java
+++ b/juick-server-jdbc/src/test/java/com/juick/service/MessageServiceTest.java
@@ -179,8 +179,11 @@ public class MessageServiceTest extends AbstractJUnit4SpringContextTests {
assertEquals("weather", msg3.getTags().get(0).getName());
assertEquals(ugnich.getUid(), userService.checkPassword(ugnich.getName(), "x"));
assertEquals(-1, userService.checkPassword(ugnich.getName(), "xy"));
+ subscriptionService.subscribeMessage(msg.getMid(), user.getUid());
subscriptionService.subscribeMessage(msg.getMid(), ugnich.getUid());
- assertEquals(1, subscriptionService.getUsersSubscribedToComments(msg.getMid(), user.getUid()).size());
+ int reply_id = messagesService.createReply(msg.getMid(), 0, ugnich_id, "comment", null);
+ assertEquals(1, subscriptionService.getUsersSubscribedToComments(msg,
+ messagesService.getReply(msg.getMid(), reply_id)).size());
assertThat(messagesService.getDiscussions(ugnich.getUid(), Instant.now().toEpochMilli()).get(0),
equalTo(msg.getMid()));
messagesService.deleteMessage(user_id, mid);