Search in sources :

Example 6 with Comment

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);
}
Also used : Comment(com.erudika.scoold.core.Comment) Profile(com.erudika.scoold.core.Profile) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 7 with Comment

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;
}
Also used : Comment(com.erudika.scoold.core.Comment) ArrayList(java.util.ArrayList)

Aggregations

Comment (com.erudika.scoold.core.Comment)7 Post (com.erudika.scoold.core.Post)4 Profile (com.erudika.scoold.core.Profile)3 ParaObject (com.erudika.para.core.ParaObject)2 ArrayList (java.util.ArrayList)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 Report (com.erudika.scoold.core.Report)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1