aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-02-01 15:19:49 +0300
committerGravatar Vitaly Takmazov2024-02-01 15:20:02 +0300
commit3cf580867600494615a7bdc9ab43ef0735d5aedb (patch)
treeb67827eb4485a9a4a72292e21d75da2e3602aff3 /src/main/java/com
parent23ea57f6436ed72881a369599c61ab655b03c23b (diff)
Do not block JDBC connection to get message tags
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index 8292f4fd..6874c7bc 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -92,10 +92,6 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
msg.setReplies(rs.getInt(10));
msg.setAttachmentType(rs.getString(11));
msg.Hidden = rs.getBoolean(13);
- if (msg.getRid() == 0) {
- msg.setTags(tagService.getMessageTags(msg.getMid()).stream()
- .map(TagStats::getTag).collect(Collectors.toSet()));
- }
msg.setRepliesBy(rs.getString(15));
msg.setText(rs.getString(16));
msg.setReplyQuote(MessageUtils.formatQuote(rs.getString(17)));
@@ -822,6 +818,9 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
List<Message> msgs = getNamedParameterJdbcTemplate().query(query,
new MapSqlParameterSource("ids", mids)
.addValue("uid", uid), messageMapper);
+
+ msgs.forEach(m -> m.setTags(tagService.getMessageTags(m.getMid()).stream()
+ .map(TagStats::getTag).collect(Collectors.toSet())));
Map<Integer, Set<Reaction>> likes = updateReactionsFor(mids);
msgs.forEach(i -> i.setReactions(likes.get(i.getMid())));
msgs.sort(Comparator.comparing(item -> mids.indexOf(item.getMid())));