X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FUnbookmarkPage.java;h=8edf2da223eeaa243cda7a7b0d23fe06e2f77ca5;hp=b568be1858f0e48e1b6272406fed3adb5f21fa96;hb=7b55e0be6a3283e43a9bbab98f82aebdd948eb33;hpb=99888ce13cc17d49f5e217ab6f2c9ad5ef168792 diff --git a/src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java b/src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java index b568be1..8edf2da 100644 --- a/src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java +++ b/src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java @@ -1,5 +1,5 @@ /* - * Sone - UnbookmarkPage.java - Copyright © 2011–2013 David Roden + * Sone - UnbookmarkPage.java - Copyright © 2011–2016 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 @@ -25,6 +25,8 @@ 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 unbookmark a post. * @@ -50,20 +52,22 @@ public class UnbookmarkPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { - super.processTemplate(request, templateContext); + protected void handleRequest(FreenetRequest request, TemplateContext templateContext) throws RedirectException { if (request.getMethod() == Method.POST) { String id = request.getHttpRequest().getPartAsStringFailsafe("post", 36); String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); - webInterface.getCore().unbookmarkPost(id); + Optional post = webInterface.getCore().getPost(id); + if (post.isPresent()) { + webInterface.getCore().unbookmarkPost(post.get()); + } throw new RedirectException(returnPage); } String id = request.getHttpRequest().getParam("post"); if (id.equals("allNotLoaded")) { Set posts = webInterface.getCore().getBookmarkedPosts(); for (Post post : posts) { - if (post.getSone() == null) { - webInterface.getCore().unbookmark(post); + if (post.isLoaded()) { + webInterface.getCore().unbookmarkPost(post); } } throw new RedirectException("bookmarks.html");