From 9a4add44ecbd32dea6ac3d30fd81ae1ac82e3dbc Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 15 Oct 2017 05:37:18 +0300 Subject: api: ImagesService --- .../com/juick/service/MessagesServiceImpl.java | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'juick-server-jdbc/src/main/java') 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 { @@ -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; } } -- cgit v1.2.3