- Post post = webInterface.getCore().getPost(postId);
- Sone currentSone = getCurrentSone(request.getToadletContext());
- if (post == null) {
- return new JsonObject().put("success", false).put("error", "invalid-post-id");
- }
- if (currentSone == null) {
- return new JsonObject().put("success", false).put("error", "auth-required");
+ Optional<Post> post = webInterface.getCore().getPost(postId);
+ if (!post.isPresent()) {
+ return createErrorJsonObject("invalid-post-id");