aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server-jdbc/src/main')
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java29
1 files changed, 20 insertions, 9 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java
index a2a6c164..f71837a7 100644
--- a/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -26,6 +26,9 @@ import com.juick.service.search.SearchService;
import com.juick.util.MessageUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.jdbc.core.ConnectionCallback;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -51,18 +54,21 @@ import java.util.List;
*/
@Repository
public class MessagesServiceImpl extends BaseJdbcService implements MessagesService {
- private final UserService userService;
- private final SearchService searchService;
+ private static final Logger logger = LoggerFactory.getLogger(MessagesServiceImpl.class);
+ @Inject
+ private UserService userService;
+ @Inject
+ private SearchService searchService;
+ @Inject
+ private ImagesService imagesService;
+ @Value("${img_path:/var/www/juick.com/i/}")
+ private String imgDir;
+ @Value("${img_url:https://i.juick.com/}")
+ private String baseImagesUrl;
@Inject
- public MessagesServiceImpl(JdbcTemplate jdbcTemplate, UserService userService, SearchService searchService) {
+ public MessagesServiceImpl(JdbcTemplate jdbcTemplate) {
super(jdbcTemplate, null);
-
- Assert.notNull(userService, "UserService must be initialized");
- this.userService = userService;
-
- Assert.notNull(searchService, "SearchService must be initialized");
- this.searchService = searchService;
}
private class MessageMapper implements RowMapper<Message> {
@@ -96,6 +102,11 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
msg.setRepliesBy(rs.getString(19));
msg.setText(rs.getString(20));
msg.setReplyQuote(MessageUtils.formatQuote(rs.getString(21)));
+ try {
+ imagesService.setAttachmentMetadata(imgDir, baseImagesUrl, msg);
+ } catch (Exception e) {
+ logger.warn("images exception", e);
+ }
return msg;
}
}