From 7692b9f126de590d8d1db3e4bed2b4c9c1345e25 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 25 Jun 2022 08:33:55 +0300 Subject: `likes` field returns recommendations count --- src/main/java/com/juick/model/Message.java | 10 +++------- src/main/java/com/juick/service/MessagesServiceImpl.java | 1 - src/main/java/com/juick/www/api/Messages.java | 4 ---- 3 files changed, 3 insertions(+), 12 deletions(-) (limited to 'src/main/java/com') diff --git a/src/main/java/com/juick/model/Message.java b/src/main/java/com/juick/model/Message.java index 0ae756b1..2a5883ac 100644 --- a/src/main/java/com/juick/model/Message.java +++ b/src/main/java/com/juick/model/Message.java @@ -71,7 +71,6 @@ public class Message implements Comparable, Serializable { private Photo photo; @XmlTransient private Attachment attachment; - private int likes; private User to; private String replyQuote; @XmlTransient @@ -88,6 +87,7 @@ public class Message implements Comparable, Serializable { public Message() { tags = new LinkedHashSet<>(); reactions = new HashSet<>(); + recommendations = new HashSet<>(); } @Override @@ -102,7 +102,7 @@ public class Message implements Comparable, Serializable { .append("Hidden", Hidden) .append("VisitorCanComment", VisitorCanComment) .append("replies", replies) - .append("likes", likes) + .append("likes", getLikes()) .append("reactions", reactions) .toString(); } @@ -260,11 +260,7 @@ public class Message implements Comparable, Serializable { @XmlTransient @Deprecated public int getLikes() { - return likes; - } - - public void setLikes(int likes) { - this.likes = likes; + return recommendations.size(); } @JsonProperty("repliesby") diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index 77200077..e54c23cb 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -92,7 +92,6 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ msg.FriendsOnly = msg.getPrivacy() < 0; msg.setReplies(rs.getInt(10)); msg.setAttachmentType(rs.getString(11)); - msg.setLikes(rs.getInt(12)); msg.Hidden = rs.getBoolean(13); String tagsStr = StringUtils.defaultString(rs.getString(14)); msg.setTags(MessageUtils.parseTags(tagsStr)); diff --git a/src/main/java/com/juick/www/api/Messages.java b/src/main/java/com/juick/www/api/Messages.java index ab222a3c..a79088d0 100644 --- a/src/main/java/com/juick/www/api/Messages.java +++ b/src/main/java/com/juick/www/api/Messages.java @@ -170,14 +170,10 @@ public class Messages { throw new HttpForbiddenException(); } else { msg.getUser().setAvatar(webApp.getAvatarUrl(msg.getUser())); - 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 replies = messagesService.getReplies(visitor, mid); // update replies counter to exclude banned replies msg.setReplies(replies.size()); - replies.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); if (!visitor.isAnonymous()) { userService.updateLastSeen(visitor); applicationEventPublisher.publishEvent(new SystemEvent(this, SystemActivity.read(visitor, msg))); -- cgit v1.2.3