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}.
*
super("unlike.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String type = request.getHttpRequest().getParam("type", null);
return createErrorJsonObject("auth-required");
}
if ("post".equals(type)) {
- currentSone.removeLikedPostId(id);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(id);
+ if (post.isPresent()) {
+ post.get().unlike(currentSone);
+ }
webInterface.getCore().touchConfiguration();
} else if ("reply".equals(type)) {
currentSone.removeLikedReplyId(id);