Skip to content

Commit

Permalink
✨ dashboard reply comment default is approved
Browse files Browse the repository at this point in the history
  • Loading branch information
hellokaton committed Jun 10, 2018
1 parent 259bedb commit 72f7816
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/main/java/com/tale/controller/ArticleController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.blade.mvc.http.Request;
import com.blade.mvc.http.Response;
import com.blade.mvc.ui.RestResponse;
import com.tale.bootstrap.TaleConst;
import com.tale.extension.Commons;
import com.tale.model.dto.ErrorCode;
import com.tale.model.dto.Types;
Expand All @@ -20,6 +21,10 @@

import java.net.URLEncoder;

import static com.tale.bootstrap.TaleConst.COMMENT_APPROVED;
import static com.tale.bootstrap.TaleConst.COMMENT_NO_AUDIT;
import static com.tale.bootstrap.TaleConst.OPTION_ALLOW_COMMENT_AUDIT;

/**
* @author biezhi
* @date 2018/6/4
Expand Down Expand Up @@ -113,6 +118,12 @@ public RestResponse<?> comment(Request request, Response response,
comments.setIp(request.address());
comments.setAgent(request.userAgent());

if (TaleConst.OPTIONS.getBoolean(OPTION_ALLOW_COMMENT_AUDIT, true)) {
comments.setStatus(COMMENT_NO_AUDIT);
} else {
comments.setStatus(COMMENT_APPROVED);
}

try {
commentsService.saveComment(comments);
response.cookie("tale_remember_author", URLEncoder.encode(comments.getAuthor(), "UTF-8"), 7 * 24 * 60 * 60);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public RestResponse<?> replyComment(@BodyParam Comments comments, Request reques
} else {
comments.setMail("");
}
comments.setStatus(TaleConst.COMMENT_APPROVED);
comments.setParent(comments.getCoid());
commentsService.saveComment(comments);
siteService.cleanCache(Types.C_STATISTICS);
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/tale/service/CommentsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public void saveComment(Comments comments) {
comments.setCreated(DateKit.nowUnix());
comments.setParent(null == comments.getCoid() ? 0 : comments.getCoid());
comments.setCoid(null);
if(TaleConst.OPTIONS.getBoolean(OPTION_ALLOW_COMMENT_AUDIT, true)){
comments.setStatus(COMMENT_NO_AUDIT);
} else {
comments.setStatus(COMMENT_APPROVED);
}
comments.save();

new Contents().set(Contents::getCommentsNum, contents.getCommentsNum() + 1).updateById(contents.getCid());
Expand Down

0 comments on commit 72f7816

Please sign in to comment.