aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/service
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-06 23:39:10 +0300
committerGravatar Vitaly Takmazov2018-10-06 23:39:10 +0300
commite882914b29f384d3f530865737cc7de3790e5b0e (patch)
treeb87b0a1055903084882bae4c8eedfbd554687105 /juick-server/src/main/java/com/juick/service
parent0b065e1e0547885294d03df54d178587d801a15a (diff)
HTML replies
Diffstat (limited to 'juick-server/src/main/java/com/juick/service')
-rw-r--r--juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java22
1 files changed, 14 insertions, 8 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 a6a38e2b..0b0a11ae 100644
--- a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -100,6 +100,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)));
+ msg.setHtml(rs.getBoolean(25));
if (StringUtils.isNotEmpty(msg.getAttachmentType())) {
try {
imagesService.setAttachmentMetadata(baseImagesUrl, msg);
@@ -337,7 +338,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 user_uri, '' as to_uri, '' as reply_uri FROM messages "
+ + "NULL as to_name, txt.updated_at, '' as user_uri, '' as to_uri, '' as reply_uri, 0 as html FROM messages "
+ "INNER JOIN users ON messages.user_id = users.id "
+ "INNER JOIN messages_txt AS txt "
+ "ON messages.message_id = txt.message_id "
@@ -345,7 +346,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, user_uri, to_uri, reply_uri",
+ + "privacy, replies, attach, tags, repliesby, q, updated_at, user_uri, to_uri, reply_uri, html",
new MessageMapper(),
mid);
if (!list.isEmpty()) {
@@ -366,7 +367,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, replies.reply_uri AS reply_uri "
+ + "q.user_uri AS to_uri, replies.reply_uri AS reply_uri, replies.html "
+ "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 "
@@ -404,6 +405,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
msg.setTo(quoteUser);
msg.setUpdatedAt(rs.getTimestamp(10).toInstant());
msg.setReplyUri(URI.create(Optional.ofNullable(rs.getString(12)).orElse(StringUtils.EMPTY)));
+ msg.setHtml(rs.getBoolean(13));
if (StringUtils.isNotEmpty(msg.getAttachmentType())) {
try {
imagesService.setAttachmentMetadata(baseImagesUrl, msg);
@@ -834,7 +836,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ "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 user_uri, "
- + "'' as to_uri, '' as reply_uri "
+ + "'' as to_uri, '' as reply_uri, 0 as html "
+ "FROM (messages INNER JOIN messages_txt "
+ "ON messages.message_id=messages_txt.message_id) "
+ "INNER JOIN users ON messages.user_id=users.id "
@@ -843,7 +845,10 @@ 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, user_uri, reply_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, html",
new MapSqlParameterSource("ids", mids)
.addValue("uid", visitor.getUid()),
new MessageMapper());
@@ -912,7 +917,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, replies.reply_uri " +
+ "qw.user_uri as to_uri, replies.reply_uri, replies.html " +
"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 " +
@@ -1027,7 +1032,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
public List<ResponseReply> getLastReplies(int hours) {
return getJdbcTemplate().query("SELECT users2.nick,replies.message_id,replies.reply_id," +
"users.nick,replies.txt," +
- "replies.ts,replies.attach,replies.ts+0 " +
+ "replies.ts,replies.attach,replies.ts+0, replies.html " +
"FROM ((replies INNER JOIN users ON replies.user_id=users.id) " +
"INNER JOIN messages ON replies.message_id=messages.message_id) " +
"INNER JOIN users AS users2 ON messages.user_id=users2.id " +
@@ -1040,6 +1045,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
reply.setDescription(rs.getString(5));
reply.setPubDate(rs.getTimestamp(6));
reply.setAttachmentType(rs.getString(7));
+ reply.setHtml(rs.getBoolean(8));
return reply;
}, -hours);
}
@@ -1097,7 +1103,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Override
public boolean updateReplyUri(Message reply, URI replyUri) {
- return jdbcTemplate.update("UPDATE replies SET reply_uri=? WHERE message_id=? AND reply_id=?",
+ return jdbcTemplate.update("UPDATE replies SET reply_uri=?, html=1 WHERE message_id=? AND reply_id=?",
replyUri.toASCIIString(), reply.getMid(), reply.getRid()) > 0;
}
}