Search in sources :

Example 1 with ReplayEmail

use of com.dimple.project.common.domain.ReplayEmail in project DimpleBlog by martin-chips.

the class FrontServiceImpl method insertComment.

@Override
public int insertComment(Comment comment) {
    comment.setAdminReply(SecurityUtils.isAdmin());
    final UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
    comment.setOs(userAgent.getOperatingSystem().getName());
    comment.setBrowser(userAgent.getBrowser().getName());
    comment.setDisplay(true);
    comment.setIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
    comment.setLocation(AddressUtils.getCityInfoByIp(comment.getIp()));
    if (comment.getParentId() != null) {
        Comment tempComment = frontMapper.selectCommentById(comment.getParentId());
        String title = frontMapper.selectBlogTitleById(comment.getPageId());
        if (tempComment.getReply()) {
            ReplayEmail replayEmail = new ReplayEmail();
            replayEmail.setCreateTime(tempComment.getCreateTime());
            replayEmail.setOriginContent(tempComment.getHtmlContent());
            replayEmail.setReplyContent(comment.getHtmlContent());
            replayEmail.setUrl(comment.getUrl());
            replayEmail.setTitle(title);
            AsyncManager.me().execute(AsyncFactory.sendReplyEmail(comment.getUrl(), comment.getHtmlContent(), comment.getNickName(), tempComment.getEmail(), replayEmail));
        }
    }
    return frontMapper.insertComment(comment);
}
Also used : Comment(com.dimple.project.blog.domain.Comment) ReplayEmail(com.dimple.project.common.domain.ReplayEmail) UserAgent(eu.bitwalker.useragentutils.UserAgent)

Aggregations

Comment (com.dimple.project.blog.domain.Comment)1 ReplayEmail (com.dimple.project.common.domain.ReplayEmail)1 UserAgent (eu.bitwalker.useragentutils.UserAgent)1