aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-11-20 00:07:06 +0300
committerGravatar Vitaly Takmazov2018-11-20 00:07:06 +0300
commit930e6ab6d604963ae6a48c58fc1bd3735071d9ee (patch)
treebb236bf36ccab695bef4d45012135c2396c84f77 /src/main/java/com/juick/server/www
parent74740d5d989f11746266a994840f89e9f6784f73 (diff)
getMessage refactoring
Diffstat (limited to 'src/main/java/com/juick/server/www')
-rw-r--r--src/main/java/com/juick/server/www/controllers/MessagesWWW.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main/java/com/juick/server/www/controllers/MessagesWWW.java b/src/main/java/com/juick/server/www/controllers/MessagesWWW.java
index 0708e27f..77ee6e15 100644
--- a/src/main/java/com/juick/server/www/controllers/MessagesWWW.java
+++ b/src/main/java/com/juick/server/www/controllers/MessagesWWW.java
@@ -496,12 +496,14 @@ public class MessagesWWW {
throw new HttpForbiddenException();
}
- com.juick.Message msg = messagesService.getMessage(mid);
+ Optional<com.juick.Message> message = messagesService.getMessage(mid);
- if (msg == null || msg.getUser().isBanned()) {
+ if (!message.isPresent() || message.get().getUser().isBanned()) {
throw new HttpNotFoundException();
}
+ Message msg = message.get();
+
com.juick.User user = userService.getUserByName(uname);
if (user.isAnonymous() || !msg.getUser().equals(user)) {
return String.format("redirect:/%s/%d", msg.getUser().getName(), mid);