change voting

This commit is contained in:
2021-10-04 11:40:51 +02:00
parent 1ba9ca32e4
commit 1fc18fdeb2
4 changed files with 63 additions and 27 deletions
@@ -112,25 +112,27 @@ public class CommentManager {
}
if (!comment.getMetadata().containsKey("points")) {
comment.getMetadata().put("points",
voteManager.getPoints(comment.getId(), Types.entry));
voteManager.getPoints(comment.getId(), Types.comment));
}
if (!comment.getMetadata().containsKey("vote")) {
comment.getMetadata().put("vote",
!voteRepository.exists(qVote.target.eq(comment.getId())
if (!comment.getMetadata().containsKey("upvoted")) {
comment.getMetadata().put("upvoted",
voteRepository.exists(qVote.target.eq(comment.getId())
.and(qVote.targetType.eq(Types.comment)).and(qVote.type.eq(VoteType.up))
.and(qVote.author.eq(username))));
}
if (!comment.getMetadata().containsKey("unvote")) {
comment.getMetadata().put("unvote",
if (!comment.getMetadata().containsKey("downvoted")) {
comment.getMetadata().put("downvoted",
voteRepository.exists(qVote.target.eq(comment.getId())
.and(qVote.targetType.eq(Types.comment))
.and(qVote.type.eq(VoteType.up).and(qVote.author.eq(username)))));
.and(qVote.type.eq(VoteType.down)).and(qVote.author.eq(username))));
}
if (!comment.getMetadata().containsKey("downvote")) {
comment.getMetadata()
.put("downvote",
!voteRepository.exists(qVote.target.eq(comment.getId())
.and(qVote.targetType.eq(Types.comment))
if (!comment.getMetadata().containsKey("unvote")) {
comment.getMetadata().put("unvote",
voteRepository.exists(
qVote.target.eq(comment.getId()).and(qVote.targetType.eq(Types.comment))
.and(qVote.author.eq(username))));
}
}