aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/api
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-04-04 20:34:45 +0300
committerGravatar Vitaly Takmazov2019-04-04 20:34:45 +0300
commit0ea0026b4ac5a26b2312e329476a632548ad5fee (patch)
tree450e56545d02912ad4adce3eaa71c7a0aff8617e /src/main/java/com/juick/server/api
parent55e6924b822417940f7aae2075acae3492684bbb (diff)
Recommendations in feeds
Diffstat (limited to 'src/main/java/com/juick/server/api')
-rw-r--r--src/main/java/com/juick/server/api/Messages.java10
1 files changed, 6 insertions, 4 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()) {