- protected void processTemplate(Request request, Template template) throws RedirectException {
- super.processTemplate(request, template);
- String postId = request.getHttpRequest().getParam("post", null);
- if (postId == null) {
- postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
- }
- Post post = webInterface.core().getPost(postId);
- Sone currentSone = getCurrentSone(request.getToadletContext());
- if (!post.getSone().equals(currentSone)) {
- throw new RedirectException("noPermission.html");
- }
- if (request.getMethod() == Method.POST) {
+ protected void handleRequest(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
+ if (request.getMethod() == Method.GET) {
+ String postId = request.getHttpRequest().getParam("post");
+ String returnPage = request.getHttpRequest().getParam("returnPage");
+ Optional<Post> post = webInterface.getCore().getPost(postId);
+ if (!post.isPresent()) {
+ throw new RedirectException("noPermission.html");
+ }
+ templateContext.set("post", post.get());
+ templateContext.set("returnPage", returnPage);
+ } else if (request.getMethod() == Method.POST) {
+ String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
+ String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
+ Optional<Post> post = webInterface.getCore().getPost(postId);
+ if (!post.isPresent() || !post.get().getSone().isLocal()) {
+ throw new RedirectException("noPermission.html");
+ }