X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FUnlikeAjaxPage.java;h=5ac0ca04a5dd5f7a3a6053e2d60359005719a5d2;hb=403b51bcf5b736808e3c554b8589759e7d3d5d47;hp=bd3c3875e34d099142268e8555afd197b291dec5;hpb=60d42fc47435de0b37710af49ad76ceb31dcfb9d;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java index bd3c387..5ac0ca0 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java @@ -22,6 +22,8 @@ import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; +import com.google.common.base.Optional; + /** * AJAX page that lets the user unlike a {@link Post}. * @@ -51,7 +53,10 @@ public class UnlikeAjaxPage extends JsonPage { return createErrorJsonObject("auth-required"); } if ("post".equals(type)) { - currentSone.removeLikedPostId(id); + Optional post = webInterface.getCore().getDatabase().getPost(id); + if (post.isPresent()) { + post.get().unlike(currentSone); + } webInterface.getCore().touchConfiguration(); } else if ("reply".equals(type)) { currentSone.removeLikedReplyId(id);