aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-10-15 05:37:18 +0300
committerGravatar Vitaly Takmazov2017-10-15 19:50:15 +0300
commit9a4add44ecbd32dea6ac3d30fd81ae1ac82e3dbc (patch)
tree38b7a4ba01d1fc47841d3ba2787209b2b2a2de9e /juick-server-jdbc/src/main
parentaeda9e3733e685f5069b5cfbb16272cd32073fa0 (diff)
api: ImagesService
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;
}
}