aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service/MessagesServiceImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/service/MessagesServiceImpl.java')
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index 8f1387cf..e2b5e2b1 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -17,12 +17,8 @@
package com.juick.service;
-import com.juick.Message;
-import com.juick.Reaction;
-import com.juick.User;
-import com.juick.model.AnonymousUser;
-import com.juick.model.PrivacyOpts;
-import com.juick.model.ResponseReply;
+import com.juick.model.*;
+import com.juick.model.User;
import com.juick.server.www.WebApp;
import com.juick.util.MessageUtils;
import org.apache.commons.collections4.CollectionUtils;
@@ -134,7 +130,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
*/
@Transactional
@Override
- public int createMessage(final int uid, final String txt, final String attachment, final List<com.juick.Tag> tags) {
+ public int createMessage(final int uid, final String txt, final String attachment, final List<Tag> tags) {
SimpleJdbcInsert simpleJdbcInsert = new SimpleJdbcInsert(getJdbcTemplate()).withTableName("messages")
.usingColumns("user_id", "attach", "ts")
.usingGeneratedKeyColumns("message_id");
@@ -370,9 +366,9 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional(readOnly = true)
@Override
- public Optional<com.juick.Message> getMessage(final int mid) {
+ public Optional<Message> getMessage(final int mid) {
- List<com.juick.Message> list = getJdbcTemplate().query(
+ List<Message> list = getJdbcTemplate().query(
"SELECT messages.message_id as mid, 0 as rid, 0 as replyto, "
+ "messages.user_id as uid, users.nick, users.banned as banned, "
+ ""
@@ -405,8 +401,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional(readOnly = true)
@Override
- public com.juick.Message getReply(final int mid, final int rid) {
- List<com.juick.Message> list = getJdbcTemplate().query(
+ public Message getReply(final int mid, final int rid) {
+ List<Message> list = getJdbcTemplate().query(
"SELECT replies.user_id, users.nick,"
+ "replies.replyto, replies.ts,"
+ "replies.attach, replies.txt, IFNULL(q.txt,t.txt) as quote, "
@@ -481,7 +477,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ "FROM messages INNER JOIN users ON messages.user_id = users.id WHERE messages.message_id = ?",
new Object[]{mid},
(rs, num) -> {
- User res = new com.juick.User();
+ User res = new User();
res.setUid(rs.getInt(1));
res.setName(rs.getString(2));
return res;
@@ -875,10 +871,10 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional(readOnly = true)
@Override
- public List<com.juick.Message> getMessages(final User visitor, final List<Integer> mids) {
+ public List<Message> getMessages(final User visitor, final List<Integer> mids) {
if (CollectionUtils.isNotEmpty(mids)) {
- List<com.juick.Message> msgs = getNamedParameterJdbcTemplate().query(
+ List<Message> msgs = getNamedParameterJdbcTemplate().query(
"WITH RECURSIVE banned(message_id, reply_id) "
+ "AS (SELECT message_id, reply_id FROM replies WHERE replies.message_id IN (:ids) "
+ "AND (EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :uid AND b.bl_user_id = replies.user_id) "