aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-common/src/main/java/com/juick/Message.java10
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Messages.java2
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java5
3 files changed, 16 insertions, 1 deletions
diff --git a/juick-common/src/main/java/com/juick/Message.java b/juick-common/src/main/java/com/juick/Message.java
index 7e03fc8e..3800f466 100644
--- a/juick-common/src/main/java/com/juick/Message.java
+++ b/juick-common/src/main/java/com/juick/Message.java
@@ -75,6 +75,8 @@ public class Message implements Comparable {
private Set<Reaction> reactions;
private boolean service;
+ private Set<String> recommendations;
+
public Message() {
tags = new ArrayList<>();
reactions = new HashSet<>();
@@ -319,4 +321,12 @@ public class Message implements Comparable {
public void setService(boolean service) {
this.service = service;
}
+
+ public Set<String> getRecommendations() {
+ return recommendations;
+ }
+
+ public void setRecommendations(Set<String> recommendations) {
+ this.recommendations = recommendations;
+ }
}
diff --git a/juick-server/src/main/java/com/juick/server/api/Messages.java b/juick-server/src/main/java/com/juick/server/api/Messages.java
index e100802f..35b7e6b2 100644
--- a/juick-server/src/main/java/com/juick/server/api/Messages.java
+++ b/juick-server/src/main/java/com/juick/server/api/Messages.java
@@ -37,6 +37,7 @@ import org.springframework.web.bind.annotation.*;
import javax.inject.Inject;
import java.io.IOException;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Objects;
@@ -149,6 +150,7 @@ public class Messages {
if (!messagesService.canViewThread(mid, visitor.getUid())) {
return FORBIDDEN;
} else {
+ msg.setRecommendations(new HashSet<>(messagesService.getMessageRecommendations(msg.getMid())));
List<com.juick.Message> replies = messagesService.getReplies(visitor, mid);
if (!visitor.isAnonymous()) {
applicationEventPublisher.publishEvent(new MessageReadEvent(this, visitor, msg));
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 88ce5cf3..0df39eb6 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
@@ -867,7 +867,10 @@ public class ServerTests {
mockMvc.perform(post("/like?mid=" + mid + "&hash=" + freefdHash))
.andExpect(status().isOk())
.andExpect(jsonPath("$.status", is("Message is added to your recommendations")));
-
+ mockMvc.perform(get("/thread?mid=" + mid + "&hash=" + freefdHash))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$[0].recommendations.length()", is(1)))
+ .andExpect(jsonPath("$[0].recommendations[0]", is(freefdName)));
mockMvc.perform(post("/like?mid=" + freefdMid + "&hash=" + freefdHash))
.andExpect(status().isForbidden());
}