X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FBookmarkPage.java;h=60ffa7adb626e2ed68c7d00a1d28bf3817a8a0a4;hb=00d6cb2688d8dda20ce55d71825b4446701a3a7a;hp=0ebf9d564dfbcf9b29c27f1d2c66677350a072bf;hpb=38cb6c5ec82298ee351d0eb15ddd8331db273af2;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/BookmarkPage.java b/src/main/java/net/pterodactylus/sone/web/BookmarkPage.java index 0ebf9d5..60ffa7a 100644 --- a/src/main/java/net/pterodactylus/sone/web/BookmarkPage.java +++ b/src/main/java/net/pterodactylus/sone/web/BookmarkPage.java @@ -1,5 +1,5 @@ /* - * Sone - BookmarkPage.java - Copyright © 2011 David Roden + * Sone - BookmarkPage.java - Copyright © 2011–2013 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,11 +17,15 @@ package net.pterodactylus.sone.web; +import net.pterodactylus.sone.data.IdBuilder; +import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import net.pterodactylus.util.web.Method; +import com.google.common.base.Optional; + /** * Page that lets the user bookmark a post. * @@ -47,12 +51,14 @@ public class BookmarkPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { - super.processTemplate(request, templateContext); + protected void processSonePage(FreenetRequest request, TemplateContext templateContext) throws RedirectException { if (request.getMethod() == Method.POST) { - String id = request.getHttpRequest().getPartAsStringFailsafe("post", 36); + String id = request.getHttpRequest().getPartAsStringFailsafe("post", IdBuilder.ID_STRING_LENGTH); String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); - webInterface.getCore().bookmarkPost(id); + Optional post = webInterface.getCore().getPost(id); + if (post.isPresent()) { + webInterface.getCore().bookmarkPost(post.get()); + } throw new RedirectException(returnPage); } }