use of com.erudika.scoold.core.Comment in project scoold by Erudika.
the class CommentController method deleteAjax.
@PostMapping("/{id}/delete")
public void deleteAjax(@PathVariable String id, HttpServletRequest req, HttpServletResponse res) {
if (utils.isAuthenticated(req)) {
Comment comment = pc.read(id);
Profile authUser = utils.getAuthUser(req);
boolean isMod = utils.isMod(authUser);
if (comment != null && (comment.getCreatorid().equals(authUser.getId()) || isMod)) {
// check parent and correct (for multi-parent-object pages)
comment.delete();
if (!isMod) {
utils.addBadgeAndUpdate(authUser, DISCIPLINED, true);
}
}
}
res.setStatus(200);
}
use of com.erudika.scoold.core.Comment in project scoold by Erudika.
the class QuestionController method reloadFirstPageOfComments.
private Post reloadFirstPageOfComments(Post post) {
List<Comment> commentz = pc.getChildren(post, Utils.type(Comment.class), post.getItemcount());
ArrayList<String> ids = new ArrayList<String>(commentz.size());
for (Comment comment : commentz) {
ids.add(comment.getId());
}
post.setCommentIds(ids);
post.setComments(commentz);
return post;
}
Aggregations