aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/service
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/service')
-rw-r--r--juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
index d556865d..a6a38e2b 100644
--- a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -99,6 +99,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
}
msg.setTo(quoteUser);
msg.setUpdatedAt(rs.getTimestamp(21).toInstant());
+ msg.setReplyUri(URI.create(Optional.ofNullable(rs.getString(24)).orElse(StringUtils.EMPTY)));
if (StringUtils.isNotEmpty(msg.getAttachmentType())) {
try {
imagesService.setAttachmentMetadata(baseImagesUrl, msg);
@@ -336,7 +337,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ "messages.readonly, messages.privacy, messages.replies,"
+ "messages.attach, COUNT(DISTINCT favorites.user_id) as likes, messages.hidden,"
+ "txt.tags, txt.repliesby, txt.txt, '' as q, messages.updated as updated, 0 as to_uid, "
- + "NULL as to_name, txt.updated_at, '' as uri, '' as to_uri FROM messages "
+ + "NULL as to_name, txt.updated_at, '' as user_uri, '' as to_uri, '' as reply_uri FROM messages "
+ "INNER JOIN users ON messages.user_id = users.id "
+ "INNER JOIN messages_txt AS txt "
+ "ON messages.message_id = txt.message_id "
@@ -344,7 +345,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ "ON messages.message_id = favorites.message_id AND favorites.like_id=1 "
+ "WHERE messages.message_id = ? "
+ "GROUP BY mid, rid, replyto, uid, nick, banned, messages.ts, readonly, "
- + "privacy, replies, attach, tags, repliesby, q, updated_at, uri",
+ + "privacy, replies, attach, tags, repliesby, q, updated_at, user_uri, to_uri, reply_uri",
new MessageMapper(),
mid);
if (!list.isEmpty()) {
@@ -365,7 +366,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ "replies.attach, replies.txt, IFNULL(q.txt,t.txt) as quote, "
+ "COALESCE(q.user_id, m.user_id) AS to_uid, COALESCE(qu.nick, mu.nick) AS to_name, "
+ "replies.updated_at, replies.user_uri as uri, "
- + "q.user_uri AS to_uri "
+ + "q.user_uri AS to_uri, replies.reply_uri AS reply_uri "
+ "FROM replies LEFT JOIN users ON replies.user_id = users.id "
+ "LEFT JOIN replies q ON replies.message_id = q.message_id and replies.replyto = q.reply_id "
+ "LEFT JOIN messages_txt t ON replies.message_id = t.message_id "
@@ -402,6 +403,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
quoteUser.setUri(URI.create(Optional.ofNullable(rs.getString(11)).orElse(StringUtils.EMPTY)));
msg.setTo(quoteUser);
msg.setUpdatedAt(rs.getTimestamp(10).toInstant());
+ msg.setReplyUri(URI.create(Optional.ofNullable(rs.getString(12)).orElse(StringUtils.EMPTY)));
if (StringUtils.isNotEmpty(msg.getAttachmentType())) {
try {
imagesService.setAttachmentMetadata(baseImagesUrl, msg);
@@ -831,7 +833,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ "messages.readonly,messages.privacy, messages.replies-COUNT(DISTINCT banned.reply_id) as replies,"
+ "messages.attach,COUNT(DISTINCT favorites.user_id) AS likes,messages.hidden,"
+ "messages_txt.tags,messages_txt.repliesby, messages_txt.txt, '' as q, "
- + "messages.updated, 0 as to_uid, NULL as to_name, messages_txt.updated_at, '' as uri, '' as to_uri "
+ + "messages.updated, 0 as to_uid, NULL as to_name, messages_txt.updated_at, '' as user_uri, "
+ + "'' as to_uri, '' as reply_uri "
+ "FROM (messages INNER JOIN messages_txt "
+ "ON messages.message_id=messages_txt.message_id) "
+ "INNER JOIN users ON messages.user_id=users.id "
@@ -840,7 +843,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ "LEFT JOIN banned "
+ "ON messages.message_id = banned.message_id "
+ "WHERE messages.message_id IN (:ids) GROUP BY "
- + "messages.message_id, rid, replyto, messages.user_id, users.nick, banned, messages.ts, messages.readonly, messages.privacy, messages.attach, messages.hidden, messages_txt.tags, messages_txt.repliesby, messages_txt.txt, q, messages.updated, to_uid, to_name, updated_at, uri",
+ + "messages.message_id, rid, replyto, messages.user_id, users.nick, banned, messages.ts, messages.readonly, messages.privacy, messages.attach, messages.hidden, messages_txt.tags, messages_txt.repliesby, messages_txt.txt, q, messages.updated, to_uid, to_name, updated_at, user_uri, reply_uri",
new MapSqlParameterSource("ids", mids)
.addValue("uid", visitor.getUid()),
new MessageMapper());
@@ -909,7 +912,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
"NOW(), " +
"COALESCE(qw.user_id, m.user_id) as to_uid, COALESCE(qu.nick, mu.nick) as to_name, " +
"replies.updated_at, replies.user_uri as uri, " +
- "qw.user_uri as to_uri " +
+ "qw.user_uri as to_uri, replies.reply_uri " +
"FROM replies LEFT JOIN users " +
"ON replies.user_id = users.id " +
"LEFT JOIN replies qw ON replies.message_id = qw.message_id and replies.replyto = qw.reply_id " +
@@ -1091,4 +1094,10 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
body, Timestamp.from(now), mid, rid) > 0;
}
}
+
+ @Override
+ public boolean updateReplyUri(Message reply, URI replyUri) {
+ return jdbcTemplate.update("UPDATE replies SET reply_uri=? WHERE message_id=? AND reply_id=?",
+ replyUri.toASCIIString(), reply.getMid(), reply.getRid()) > 0;
+ }
}