aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www
diff options
context:
space:
mode:
authorGravatar KillyMXI2017-10-05 06:00:24 +0300
committerGravatar KillyMXI2017-10-05 06:00:24 +0300
commit9cd6679f3f2804bc0b22cfb816f40b47846080cf (patch)
tree08126a272cd2e6fa955edbf1845390135e9358cd /juick-www/src/main/java/com/juick/www
parent6cdf962a478d76f1d32d31e9e9e1797cbc14c16f (diff)
www: don't show reply forms in readonly thread
Diffstat (limited to 'juick-www/src/main/java/com/juick/www')
-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()));
}
}