aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/server')
-rw-r--r--src/main/java/com/juick/server/api/Messages.java10
-rw-r--r--src/main/java/com/juick/server/www/controllers/MessagesWWW.java6
2 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/com/juick/server/api/Messages.java b/src/main/java/com/juick/server/api/Messages.java
index 5a4d8c31..60e05d6d 100644
--- a/src/main/java/com/juick/server/api/Messages.java
+++ b/src/main/java/com/juick/server/api/Messages.java
@@ -31,6 +31,7 @@ import com.juick.service.MessagesService;
import com.juick.service.TagService;
import com.juick.service.UserService;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.core.io.Resource;
@@ -43,6 +44,7 @@ import org.springframework.web.bind.annotation.*;
import javax.inject.Inject;
import java.io.IOException;
import java.util.*;
+import java.util.stream.Collectors;
/**
* @author ugnich
@@ -182,10 +184,10 @@ public class Messages {
throw new HttpNotFoundException();
}
msg.getUser().setAvatar(webApp.getAvatarUrl(msg.getUser()));
- msg.setRecommendations(new HashSet<>(messagesService.getMessageRecommendations(msg.getMid())));
- msg.getRecommendations().forEach(r -> {
- r.setAvatar(webApp.getAvatarUrl(r));
- });
+ msg.setRecommendations(new HashSet<>(messagesService.getMessagesRecommendations(
+ Collections.singletonList(msg.getMid()))
+ .stream().map(Pair::getRight).collect(Collectors.toList())));
+ msg.getRecommendations().forEach(r -> r.setAvatar(webApp.getAvatarUrl(r)));
List<com.juick.Message> replies = messagesService.getReplies(visitor, mid);
replies.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser())));
if (!visitor.isAnonymous()) {
diff --git a/src/main/java/com/juick/server/www/controllers/MessagesWWW.java b/src/main/java/com/juick/server/www/controllers/MessagesWWW.java
index 4410f591..5d82b686 100644
--- a/src/main/java/com/juick/server/www/controllers/MessagesWWW.java
+++ b/src/main/java/com/juick/server/www/controllers/MessagesWWW.java
@@ -29,6 +29,7 @@ import com.juick.service.*;
import com.juick.util.MessageUtils;
import org.apache.commons.codec.CharEncoding;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.text.StringEscapeUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -47,6 +48,7 @@ import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -572,7 +574,9 @@ public class MessagesWWW {
model.addAttribute("headers", headers);
model.addAttribute("visitorSubscribed", messagesService.isSubscribed(visitor.getUid(), msg.getMid()));
model.addAttribute("visitorInBL", userService.isInBL(msg.getUser().getUid(), visitor.getUid()));
- model.addAttribute("recomm", messagesService.getMessageRecommendations(msg.getMid()));
+ model.addAttribute("recomm", messagesService.getMessagesRecommendations(
+ Collections.singletonList(msg.getMid())).stream()
+ .map(Pair::getRight).collect(Collectors.toList()));
List<Integer> blUIDs = new ArrayList<>();
for (Message reply : replies) {
if (reply.getUser().getUid() != msg.getUser().getUid()