X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnbookmarkAjaxPage.java;h=94dd268b5e83c7b6ddb7fa93a628aa37e57bfede;hp=6a9f8fe96ba38b096741ad0da77e82a415fa77b2;hb=7b55e0be6a3283e43a9bbab98f82aebdd948eb33;hpb=45f92ec63dbf8134d92ceed67294faa38117b195 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.java index 6a9f8fe..94dd268 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - UnbookmarkAjaxPage.java - Copyright © 2011 David Roden + * Sone - UnbookmarkAjaxPage.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 @@ -17,9 +17,11 @@ package net.pterodactylus.sone.web.ajax; +import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; -import net.pterodactylus.util.json.JsonObject; + +import com.google.common.base.Optional; /** * AJAX page that lets the user unbookmark a post. @@ -46,12 +48,15 @@ public class UnbookmarkAjaxPage extends JsonPage { * {@inheritDoc} */ @Override - protected JsonObject createJsonObject(FreenetRequest request) { + protected JsonReturnObject createJsonObject(FreenetRequest request) { String id = request.getHttpRequest().getParam("post", null); if ((id == null) || (id.length() == 0)) { return createErrorJsonObject("invalid-post-id"); } - webInterface.getCore().unbookmarkPost(id); + Optional post = webInterface.getCore().getPost(id); + if (post.isPresent()) { + webInterface.getCore().unbookmarkPost(post.get()); + } return createSuccessJsonObject(); }