aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/UserThread.java21
1 files changed, 11 insertions, 10 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/UserThread.java b/juick-www/src/main/java/com/juick/www/controllers/UserThread.java
index 46ac485f..b2c3c1f5 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/UserThread.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/UserThread.java
@@ -38,6 +38,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import javax.inject.Inject;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.function.BooleanSupplier;
import java.util.List;
import java.util.stream.Collectors;
@@ -78,8 +79,9 @@ public class UserThread {
}
msg.VisitorCanComment = visitor.getUid() > 0;
if (visitor.getUid() > 0) {
- msg.VisitorCanComment = visitor.getUid() == msg.getUser().getUid()
- || !userService.isInBL(msg.getUser().getUid(), visitor.getUid());
+ boolean isMsgAuthor = visitor.getUid() == msg.getUser().getUid();
+ boolean isInBL = userService.isInBL(msg.getUser().getUid(), visitor.getUid());
+ msg.VisitorCanComment = isMsgAuthor || !(msg.ReadOnly || isInBL);
}
model.addAttribute("msg", msg);
@@ -157,14 +159,13 @@ public class UserThread {
reply.setReplyto(0);
}
}
- if (visitor.getUid() > 0 && msg.getUser().getUid() == visitor.getUid()) {
- reply.VisitorCanComment = true;
- } else if (visitor.getUid() > 0 && msg.VisitorCanComment) {
- List<Integer> blUIDs2 = userService.checkBL(visitor.getUid(), blUIDs);
- reply.VisitorCanComment = reply.getUser().getUid() == visitor.getUid()
- || !blUIDs2.contains(reply.getUser().getUid());
- } else {
- reply.VisitorCanComment = false;
+
+ reply.VisitorCanComment = visitor.getUid() > 0;
+ if (visitor.getUid() > 0) {
+ boolean isMsgAuthor = visitor.getUid() == msg.getUser().getUid();
+ boolean isReplyAuthor = visitor.getUid() == reply.getUser().getUid();
+ BooleanSupplier isInBL2 = () -> userService.checkBL(visitor.getUid(), blUIDs).contains(reply.getUser().getUid());
+ reply.VisitorCanComment = isMsgAuthor || (!msg.ReadOnly && (isReplyAuthor || !isInBL2.getAsBoolean()));
}
}