X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FUnlikePage.java;h=48e5ab702c085be3f52e7b08258aa36901f81bcd;hb=403b51bcf5b736808e3c554b8589759e7d3d5d47;hp=0670a184e57769f40dac62f99794552e950fd1b0;hpb=60d42fc47435de0b37710af49ad76ceb31dcfb9d;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/UnlikePage.java b/src/main/java/net/pterodactylus/sone/web/UnlikePage.java index 0670a18..48e5ab7 100644 --- a/src/main/java/net/pterodactylus/sone/web/UnlikePage.java +++ b/src/main/java/net/pterodactylus/sone/web/UnlikePage.java @@ -24,6 +24,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 unlike a {@link Post}. * @@ -56,7 +58,10 @@ public class UnlikePage extends SoneTemplatePage { String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); Sone currentSone = getCurrentSone(request.getToadletContext()); if ("post".equals(type)) { - currentSone.removeLikedPostId(id); + Optional post = webInterface.getCore().getDatabase().getPost(id); + if (post.isPresent()) { + post.get().unlike(currentSone); + } } else if ("reply".equals(type)) { currentSone.removeLikedReplyId(id); }